Comparing version 5.11.1 to 5.12.0
@@ -1,2 +0,2 @@ | ||
export declare const publicKeyToAddress: (publicKey: string) => string; | ||
export declare const publicKeyToAddress: (publicKey: string, otherAddress: string) => string; | ||
//# sourceMappingURL=bip122.d.ts.map |
@@ -530,6 +530,8 @@ import * as u8a from 'uint8arrays'; | ||
const publicKeyToAddress$1 = publicKey => { | ||
const publicKeyToAddress$1 = (publicKey, otherAddress) => { | ||
// Use the same version/prefix byte as the given address. | ||
const version = u8a.toString(base58ToBytes(otherAddress).slice(0, 1), 'hex'); | ||
const publicKeyBuffer = u8a.fromString(publicKey, 'hex'); | ||
const publicKeyHash = new Ripemd160().update(sha256(publicKeyBuffer)).digest(); | ||
const step1 = '00' + u8a.toString(publicKeyHash, 'hex'); | ||
const step1 = version + u8a.toString(publicKeyHash, 'hex'); | ||
const step2 = sha256(u8a.fromString(step1, 'hex')); | ||
@@ -557,3 +559,3 @@ const step3 = sha256(step2); | ||
case 'bip122': | ||
chain[chain.length - 1] = publicKeyToAddress$1(publicKey); | ||
chain[chain.length - 1] = publicKeyToAddress$1(publicKey, chain[chain.length - 1]); | ||
break; | ||
@@ -560,0 +562,0 @@ |
{ | ||
"name": "did-jwt", | ||
"version": "5.11.1", | ||
"version": "5.12.0", | ||
"description": "Library for Signing and Verifying JWTs that use DIDs as issuers and JWEs that use DIDs as recipients", | ||
@@ -5,0 +5,0 @@ "source": "src/index.ts", |
import * as u8a from 'uint8arrays' | ||
import { bytesToBase58 } from '../util' | ||
import { bytesToBase58, base58ToBytes } from '../util' | ||
import { sha256 } from '../Digest' | ||
import { Ripemd160 } from './utils/ripemd160' | ||
export const publicKeyToAddress = (publicKey: string): string => { | ||
export const publicKeyToAddress = (publicKey: string, otherAddress: string): string => { | ||
// Use the same version/prefix byte as the given address. | ||
const version = u8a.toString(base58ToBytes(otherAddress).slice(0, 1), 'hex') | ||
const publicKeyBuffer = u8a.fromString(publicKey, 'hex') | ||
const publicKeyHash = new Ripemd160().update(sha256(publicKeyBuffer)).digest() | ||
const step1 = '00' + u8a.toString(publicKeyHash, 'hex') | ||
const step1 = version + u8a.toString(publicKeyHash, 'hex') | ||
const step2 = sha256(u8a.fromString(step1, 'hex')) | ||
@@ -11,0 +13,0 @@ const step3 = sha256(step2) |
@@ -10,3 +10,3 @@ import { publicKeyToAddress as bip122 } from './bip122' | ||
case 'bip122': | ||
chain[chain.length - 1] = bip122(publicKey) | ||
chain[chain.length - 1] = bip122(publicKey, chain[chain.length - 1]) | ||
break | ||
@@ -13,0 +13,0 @@ case 'cosmos': |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1305569
11963