Add pair.unlock as equivalent to pair.lock (#877)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user