本文整理匯總了TypeScript中elliptic.ec.keyFromPrivate方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ec.keyFromPrivate方法的具體用法?TypeScript ec.keyFromPrivate怎麽用?TypeScript ec.keyFromPrivate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類elliptic.ec
的用法示例。
在下文中一共展示了ec.keyFromPrivate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
/**
* Passing an external key will import it, otherwise a keypair will
* be generated.
*/
constructor(ext?: string) {
if (ext) {
const keyParts = ext.split("|");
const d = Base64.decode(keyParts[2]);
this.keyPair = elliptic.keyFromPrivate(Buffer.from(d));
} else {
// Generate our own key since we have a good PRNG
const d = new Uint8Array(32);
crypto.getRandomValues(d);
this.keyPair = elliptic.keyFromPrivate(Buffer.from(d));
}
}
示例2: function
export const sign = function(hash: Buffer, privateKey: Buffer): string {
const signature = secp256k1.keyFromPrivate(privateKey).sign(hash, { canonical: true });
return "0x" + Buffer.concat([signature.r.toBuffer(), signature.s.toBuffer(), Buffer.from([signature.recoveryParam])]).toString("hex"); /* tslint:disable:max-line-length */
};
示例3: getHexFromBN
const results = evilHexes.map((hex) => {
const ephemeralSK = ecurve.keyFromPrivate(hex)
const ephemeralPK = ephemeralSK.getPublic()
const sharedSecret = ephemeralSK.derive(ephemeralPK)
return getHexFromBN(sharedSecret).length === 64
})