Add pair.unlock as equivalent to pair.lock (#877)

This commit is contained in:
Jaco Greeff
2021-02-09 17:35:59 +01:00
committed by GitHub
parent 12f3f8695f
commit 8b443dfa4b
4 changed files with 19 additions and 5 deletions
+7
View File
@@ -1,5 +1,12 @@
# CHANGELOG
## 5.6.x
Changes:
- Add `unlock(password)` to keypair (less confusing than only having `decodePkcs8`, equivalent to `lock()`)
## 5.6.2 Feb 8, 2021
Changes:
+3
View File
@@ -178,6 +178,9 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
return pairToJson(type, { address, meta }, recode(passphrase), !!passphrase);
},
unlock: (passphrase?: string): void => {
return decodePkcs8(passphrase);
},
verify: (message: string | Uint8Array, signature: Uint8Array): boolean => {
return signatureVerify(message, signature, TYPE_ADDRESS[type](publicKey)).isValid;
},
+3
View File
@@ -52,6 +52,9 @@ export function nobody (): KeyringPair {
json,
type: 'ed25519',
// eslint-disable-next-line @typescript-eslint/no-unused-vars
unlock: (passphrase?: string): void =>
undefined,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
verify: (message: Uint8Array, signature: Uint8Array): boolean =>
false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
+6 -5
View File
@@ -40,13 +40,14 @@ export interface KeyringPair {
readonly publicKey: Uint8Array;
readonly type: KeypairType;
decodePkcs8: (passphrase?: string, encoded?: Uint8Array) => void;
derive: (suri: string, meta?: KeyringPair$Meta) => KeyringPair;
encodePkcs8: (passphrase?: string) => Uint8Array;
lock: () => void;
setMeta: (meta: KeyringPair$Meta) => void;
decodePkcs8 (passphrase?: string, encoded?: Uint8Array): void;
derive (suri: string, meta?: KeyringPair$Meta): KeyringPair;
encodePkcs8 (passphrase?: string): Uint8Array;
lock (): void;
setMeta (meta: KeyringPair$Meta): void;
sign (message: string | Uint8Array, options?: SignOptions): Uint8Array;
toJson (passphrase?: string): KeyringPair$Json;
unlock (passphrase?: string): void;
verify (message: string | Uint8Array, signature: Uint8Array): boolean;
vrfSign (message: string | Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array;
vrfVerify (message: string | Uint8Array, vrfResult: Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): boolean;