@did-btcr2/method 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +314 -312
- package/dist/browser.mjs +314 -312
- package/dist/cjs/core/beacon/aggregation/protocol/nostr.js +4 -4
- package/dist/cjs/core/beacon/aggregation/protocol/nostr.js.map +1 -1
- package/dist/cjs/core/beacon/cid-aggregate.js +2 -2
- package/dist/cjs/core/beacon/singleton.js +2 -2
- package/dist/cjs/core/beacon/singleton.js.map +1 -1
- package/dist/cjs/core/crud/deactivate.js +4 -4
- package/dist/cjs/core/crud/deactivate.js.map +1 -1
- package/dist/cjs/core/crud/read.js +20 -20
- package/dist/cjs/core/crud/read.js.map +1 -1
- package/dist/cjs/core/crud/update.js +2 -2
- package/dist/cjs/core/crud/update.js.map +1 -1
- package/dist/cjs/core/key-manager/index.js +5 -5
- package/dist/cjs/core/key-manager/index.js.map +1 -1
- package/dist/cjs/did-btcr2.js +8 -20
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/appendix.js +4 -4
- package/dist/cjs/utils/appendix.js.map +1 -1
- package/dist/cjs/utils/did-document-builder.js +1 -1
- package/dist/cjs/utils/did-document-builder.js.map +1 -1
- package/dist/cjs/utils/did-document.js +62 -14
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/cjs/utils/identifier.js +5 -5
- package/dist/cjs/utils/identifier.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/protocol/nostr.js +4 -4
- package/dist/esm/core/beacon/aggregation/protocol/nostr.js.map +1 -1
- package/dist/esm/core/beacon/cid-aggregate.js +2 -2
- package/dist/esm/core/beacon/singleton.js +2 -2
- package/dist/esm/core/beacon/singleton.js.map +1 -1
- package/dist/esm/core/crud/deactivate.js +4 -4
- package/dist/esm/core/crud/deactivate.js.map +1 -1
- package/dist/esm/core/crud/read.js +20 -20
- package/dist/esm/core/crud/read.js.map +1 -1
- package/dist/esm/core/crud/update.js +2 -2
- package/dist/esm/core/crud/update.js.map +1 -1
- package/dist/esm/core/key-manager/index.js +5 -5
- package/dist/esm/core/key-manager/index.js.map +1 -1
- package/dist/esm/did-btcr2.js +8 -20
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/appendix.js +4 -4
- package/dist/esm/utils/appendix.js.map +1 -1
- package/dist/esm/utils/did-document-builder.js +1 -1
- package/dist/esm/utils/did-document-builder.js.map +1 -1
- package/dist/esm/utils/did-document.js +62 -14
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/esm/utils/identifier.js +5 -5
- package/dist/esm/utils/identifier.js.map +1 -1
- package/dist/types/core/beacon/aggregation/protocol/nostr.d.ts +1 -1
- package/dist/types/core/beacon/cid-aggregate.d.ts +2 -2
- package/dist/types/core/crud/deactivate.d.ts +4 -4
- package/dist/types/core/crud/deactivate.d.ts.map +1 -1
- package/dist/types/core/crud/read.d.ts +4 -4
- package/dist/types/core/crud/read.d.ts.map +1 -1
- package/dist/types/core/crud/update.d.ts +10 -0
- package/dist/types/core/crud/update.d.ts.map +1 -1
- package/dist/types/core/key-manager/index.d.ts +6 -6
- package/dist/types/core/key-manager/index.d.ts.map +1 -1
- package/dist/types/core/key-manager/interface.d.ts +3 -3
- package/dist/types/core/key-manager/interface.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +15 -5
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/crud.d.ts +1 -4
- package/dist/types/interfaces/crud.d.ts.map +1 -1
- package/dist/types/types/crud.d.ts +5 -5
- package/dist/types/types/crud.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +7 -7
- package/dist/types/utils/appendix.d.ts.map +1 -1
- package/dist/types/utils/did-document-builder.d.ts +1 -1
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +26 -11
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/dist/types/utils/identifier.d.ts +2 -2
- package/dist/types/utils/identifier.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/core/beacon/aggregation/protocol/nostr.ts +4 -4
- package/src/core/beacon/cid-aggregate.ts +2 -2
- package/src/core/beacon/singleton.ts +2 -2
- package/src/core/crud/deactivate.ts +4 -4
- package/src/core/crud/read.ts +21 -21
- package/src/core/crud/update.ts +14 -2
- package/src/core/key-manager/index.ts +7 -7
- package/src/core/key-manager/interface.ts +3 -3
- package/src/did-btcr2.ts +24 -25
- package/src/index.ts +0 -1
- package/src/interfaces/crud.ts +1 -4
- package/src/types/crud.ts +5 -5
- package/src/utils/appendix.ts +9 -9
- package/src/utils/did-document-builder.ts +1 -1
- package/src/utils/did-document.ts +73 -17
- package/src/utils/identifier.ts +5 -5
- package/dist/cjs/core/crud/create.js +0 -102
- package/dist/cjs/core/crud/create.js.map +0 -1
- package/dist/esm/core/crud/create.js +0 -102
- package/dist/esm/core/crud/create.js.map +0 -1
- package/dist/types/core/crud/create.d.ts +0 -92
- package/dist/types/core/crud/create.d.ts.map +0 -1
- package/src/core/crud/create.ts +0 -160
package/dist/browser.mjs
CHANGED
|
@@ -7359,7 +7359,7 @@ var require_dist2 = __commonJS({
|
|
|
7359
7359
|
return false;
|
|
7360
7360
|
}
|
|
7361
7361
|
}
|
|
7362
|
-
function
|
|
7362
|
+
function isPoint4(p3) {
|
|
7363
7363
|
return _isPoint(p3, false);
|
|
7364
7364
|
}
|
|
7365
7365
|
function isPointCompressed(p3) {
|
|
@@ -7386,7 +7386,7 @@ var require_dist2 = __commonJS({
|
|
|
7386
7386
|
});
|
|
7387
7387
|
}
|
|
7388
7388
|
function xOnlyPointFromPoint(p3) {
|
|
7389
|
-
if (!
|
|
7389
|
+
if (!isPoint4(p3)) {
|
|
7390
7390
|
throw new Error(THROW_BAD_POINT);
|
|
7391
7391
|
}
|
|
7392
7392
|
return p3.slice(1, 33);
|
|
@@ -7406,13 +7406,13 @@ var require_dist2 = __commonJS({
|
|
|
7406
7406
|
return xOnlyPointFromPoint(pointFromScalar2(d2));
|
|
7407
7407
|
}
|
|
7408
7408
|
function pointCompress(p3, compressed) {
|
|
7409
|
-
if (!
|
|
7409
|
+
if (!isPoint4(p3)) {
|
|
7410
7410
|
throw new Error(THROW_BAD_POINT);
|
|
7411
7411
|
}
|
|
7412
7412
|
return fromHex2(p3).toRawBytes(assumeCompression(compressed, p3));
|
|
7413
7413
|
}
|
|
7414
7414
|
function pointMultiply(a3, tweak, compressed) {
|
|
7415
|
-
if (!
|
|
7415
|
+
if (!isPoint4(a3)) {
|
|
7416
7416
|
throw new Error(THROW_BAD_POINT);
|
|
7417
7417
|
}
|
|
7418
7418
|
if (!isTweak(tweak)) {
|
|
@@ -7423,7 +7423,7 @@ var require_dist2 = __commonJS({
|
|
|
7423
7423
|
);
|
|
7424
7424
|
}
|
|
7425
7425
|
function pointAdd2(a3, b2, compressed) {
|
|
7426
|
-
if (!
|
|
7426
|
+
if (!isPoint4(a3) || !isPoint4(b2)) {
|
|
7427
7427
|
throw new Error(THROW_BAD_POINT);
|
|
7428
7428
|
}
|
|
7429
7429
|
return throwToNull(() => {
|
|
@@ -7437,7 +7437,7 @@ var require_dist2 = __commonJS({
|
|
|
7437
7437
|
});
|
|
7438
7438
|
}
|
|
7439
7439
|
function pointAddScalar(p3, tweak, compressed) {
|
|
7440
|
-
if (!
|
|
7440
|
+
if (!isPoint4(p3)) {
|
|
7441
7441
|
throw new Error(THROW_BAD_POINT);
|
|
7442
7442
|
}
|
|
7443
7443
|
if (!isTweak(tweak)) {
|
|
@@ -7531,7 +7531,7 @@ var require_dist2 = __commonJS({
|
|
|
7531
7531
|
return Q.toRawBytes(assumeCompression(compressed));
|
|
7532
7532
|
}
|
|
7533
7533
|
function verify(h2, Q, signature2, strict) {
|
|
7534
|
-
if (!
|
|
7534
|
+
if (!isPoint4(Q)) {
|
|
7535
7535
|
throw new Error(THROW_BAD_POINT);
|
|
7536
7536
|
}
|
|
7537
7537
|
if (!isSignature(signature2)) {
|
|
@@ -7554,7 +7554,7 @@ var require_dist2 = __commonJS({
|
|
|
7554
7554
|
}
|
|
7555
7555
|
return secp256k13.schnorr.verify(signature2, h2, Q);
|
|
7556
7556
|
}
|
|
7557
|
-
exports.isPoint =
|
|
7557
|
+
exports.isPoint = isPoint4;
|
|
7558
7558
|
exports.isPointCompressed = isPointCompressed;
|
|
7559
7559
|
exports.isPrivate = isPrivate3;
|
|
7560
7560
|
exports.isXOnlyPoint = isXOnlyPoint;
|
|
@@ -30635,7 +30635,7 @@ var require_eddsa = __commonJS({
|
|
|
30635
30635
|
EDDSA.prototype.decodeInt = function decodeInt(bytes3) {
|
|
30636
30636
|
return utils3.intFromLE(bytes3);
|
|
30637
30637
|
};
|
|
30638
|
-
EDDSA.prototype.isPoint = function
|
|
30638
|
+
EDDSA.prototype.isPoint = function isPoint4(val) {
|
|
30639
30639
|
return val instanceof this.pointClass;
|
|
30640
30640
|
};
|
|
30641
30641
|
}
|
|
@@ -32247,13 +32247,13 @@ var require_asn12 = __commonJS({
|
|
|
32247
32247
|
).optional()
|
|
32248
32248
|
);
|
|
32249
32249
|
});
|
|
32250
|
-
var
|
|
32250
|
+
var PublicKey3 = asn1.define("SubjectPublicKeyInfo", function() {
|
|
32251
32251
|
this.seq().obj(
|
|
32252
32252
|
this.key("algorithm").use(AlgorithmIdentifier2),
|
|
32253
32253
|
this.key("subjectPublicKey").bitstr()
|
|
32254
32254
|
);
|
|
32255
32255
|
});
|
|
32256
|
-
exports.PublicKey =
|
|
32256
|
+
exports.PublicKey = PublicKey3;
|
|
32257
32257
|
var PrivateKeyInfo2 = asn1.define("PrivateKeyInfo", function() {
|
|
32258
32258
|
this.seq().obj(
|
|
32259
32259
|
this.key("version")["int"](),
|
|
@@ -45001,11 +45001,11 @@ var require_Reflect = __commonJS({
|
|
|
45001
45001
|
};
|
|
45002
45002
|
metadataRegistry.registerProvider(provider);
|
|
45003
45003
|
return provider;
|
|
45004
|
-
function GetOrCreateMetadataMap(O, P3,
|
|
45004
|
+
function GetOrCreateMetadataMap(O, P3, Create) {
|
|
45005
45005
|
var targetMetadata = metadata2.get(O);
|
|
45006
45006
|
var createdTargetMetadata = false;
|
|
45007
45007
|
if (IsUndefined(targetMetadata)) {
|
|
45008
|
-
if (!
|
|
45008
|
+
if (!Create)
|
|
45009
45009
|
return void 0;
|
|
45010
45010
|
targetMetadata = new _Map();
|
|
45011
45011
|
metadata2.set(O, targetMetadata);
|
|
@@ -45013,7 +45013,7 @@ var require_Reflect = __commonJS({
|
|
|
45013
45013
|
}
|
|
45014
45014
|
var metadataMap = targetMetadata.get(P3);
|
|
45015
45015
|
if (IsUndefined(metadataMap)) {
|
|
45016
|
-
if (!
|
|
45016
|
+
if (!Create)
|
|
45017
45017
|
return void 0;
|
|
45018
45018
|
metadataMap = new _Map();
|
|
45019
45019
|
targetMetadata.set(P3, metadataMap);
|
|
@@ -45140,12 +45140,12 @@ var require_Reflect = __commonJS({
|
|
|
45140
45140
|
};
|
|
45141
45141
|
return provider;
|
|
45142
45142
|
}
|
|
45143
|
-
function GetMetadataProvider(O, P3,
|
|
45143
|
+
function GetMetadataProvider(O, P3, Create) {
|
|
45144
45144
|
var registeredProvider = metadataRegistry.getProvider(O, P3);
|
|
45145
45145
|
if (!IsUndefined(registeredProvider)) {
|
|
45146
45146
|
return registeredProvider;
|
|
45147
45147
|
}
|
|
45148
|
-
if (
|
|
45148
|
+
if (Create) {
|
|
45149
45149
|
if (metadataRegistry.setProvider(O, P3, metadataProvider)) {
|
|
45150
45150
|
return metadataProvider;
|
|
45151
45151
|
}
|
|
@@ -48429,8 +48429,8 @@ var CIDAggregateBeacon = class _CIDAggregateBeacon extends Beacon {
|
|
|
48429
48429
|
*
|
|
48430
48430
|
* The Broadcast CIDAggregate Beacon Signal algorithm involving two roles: a set of cohort participants and a Beacon
|
|
48431
48431
|
* coordinator. The Beacon coordinator collects individual DID Update Payload Content Identifiers (CIDs) for specific
|
|
48432
|
-
* did:
|
|
48433
|
-
* (CAS). The CID for the DID Update Bundle is included in a Partially Signed Bitcoin Transaction (PSBT) transaction
|
|
48432
|
+
* did:btcr2 idntifiers and aggregates them into a DID Update Bundle, which is then published to a Content Addressable
|
|
48433
|
+
* Storage (CAS). The CID for the DID Update Bundle is included in a Partially Signed Bitcoin Transaction (PSBT) transaction
|
|
48434
48434
|
* output spent from the Beacon’s n-of-n address. Each of the n cohort participants in the Beacon MUST sign the
|
|
48435
48435
|
* transaction before it can be broadcast to the network. It is RECOMMENDED that cohort participants keep a copy of
|
|
48436
48436
|
* the DID Update Bundle and separately pin it to the CAS.
|
|
@@ -48685,21 +48685,21 @@ init_shim();
|
|
|
48685
48685
|
var TXIN_WITNESS_COINBASE = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
48686
48686
|
var GENESIS_TX_ID = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";
|
|
48687
48687
|
var DEFAULT_BITCOIN_NETWORK_CONFIG = {
|
|
48688
|
-
|
|
48688
|
+
bitcoin: {
|
|
48689
48689
|
rpc: void 0,
|
|
48690
|
-
rest: { host: "https://mempool.
|
|
48690
|
+
rest: { host: "https://mempool.holdings/api" }
|
|
48691
48691
|
},
|
|
48692
48692
|
testnet3: {
|
|
48693
48693
|
rpc: void 0,
|
|
48694
|
-
rest: { host: "https://mempool.
|
|
48694
|
+
rest: { host: "https://mempool.holdings/testnet/api" }
|
|
48695
48695
|
},
|
|
48696
48696
|
testnet4: {
|
|
48697
48697
|
rpc: void 0,
|
|
48698
|
-
rest: { host: "https://mempool.
|
|
48698
|
+
rest: { host: "https://mempool.holdings/testnet4/api" }
|
|
48699
48699
|
},
|
|
48700
48700
|
signet: {
|
|
48701
48701
|
rpc: void 0,
|
|
48702
|
-
rest: { host: "https://mempool.
|
|
48702
|
+
rest: { host: "https://mempool.holdings/signet/api" }
|
|
48703
48703
|
},
|
|
48704
48704
|
mutinynet: {
|
|
48705
48705
|
rpc: void 0,
|
|
@@ -48835,7 +48835,7 @@ var BitcoinRpcClientConfig = class _BitcoinRpcClientConfig {
|
|
|
48835
48835
|
allowDefaultWallet;
|
|
48836
48836
|
constructor(options2 = {
|
|
48837
48837
|
headers: {},
|
|
48838
|
-
host: "localhost",
|
|
48838
|
+
host: "http://localhost",
|
|
48839
48839
|
logger: console,
|
|
48840
48840
|
password: "",
|
|
48841
48841
|
timeout: 3e4,
|
|
@@ -48904,8 +48904,8 @@ var JsonRpcTransport = class {
|
|
|
48904
48904
|
u.password = "";
|
|
48905
48905
|
this.url = u.toString().replace(/\/+$/, "");
|
|
48906
48906
|
}
|
|
48907
|
-
} catch {
|
|
48908
|
-
console.error(
|
|
48907
|
+
} catch (error) {
|
|
48908
|
+
console.error(`Invalid URL in Bitcoin RPC config: ${this.url}`, error);
|
|
48909
48909
|
}
|
|
48910
48910
|
}
|
|
48911
48911
|
}
|
|
@@ -57621,7 +57621,7 @@ function getNetwork(network) {
|
|
|
57621
57621
|
// ../bitcoin/dist/esm/bitcoin.js
|
|
57622
57622
|
var BitcoinNetworkConnection = class {
|
|
57623
57623
|
network;
|
|
57624
|
-
|
|
57624
|
+
bitcoin;
|
|
57625
57625
|
testnet3;
|
|
57626
57626
|
testnet4;
|
|
57627
57627
|
signet;
|
|
@@ -57642,7 +57642,7 @@ var BitcoinNetworkConnection = class {
|
|
|
57642
57642
|
throw new MethodError("Parsing failed: malformed BITCOIN_NETWORK_CONFIG", "MISSING_MALFORMED_BITCOIN_NETWORK_CONFIG", { BITCOIN_NETWORK_CONFIG });
|
|
57643
57643
|
}
|
|
57644
57644
|
const networkConfigs = JSON.parse(BITCOIN_NETWORK_CONFIG);
|
|
57645
|
-
const networks2 = ["
|
|
57645
|
+
const networks2 = ["bitcoin", "testnet3", "testnet4", "signet", "mutinynet", "regtest"];
|
|
57646
57646
|
for (const network of networks2) {
|
|
57647
57647
|
const networkConfig = configs?.[network] ?? networkConfigs[network];
|
|
57648
57648
|
if (networkConfig) {
|
|
@@ -57666,7 +57666,7 @@ var BitcoinNetworkConnection = class {
|
|
|
57666
57666
|
}
|
|
57667
57667
|
/**
|
|
57668
57668
|
* Get the Bitcoin network configuration for a specific network.
|
|
57669
|
-
* @param {keyof AvailableNetworks} network - The Bitcoin network (e.g., '
|
|
57669
|
+
* @param {keyof AvailableNetworks} network - The Bitcoin network (e.g., 'bitcoin', 'testnet3', 'signet', 'regtest').
|
|
57670
57670
|
* @returns {Bitcoin} The Bitcoin object.
|
|
57671
57671
|
*/
|
|
57672
57672
|
getNetworkConnection(network) {
|
|
@@ -57678,7 +57678,7 @@ var BitcoinNetworkConnection = class {
|
|
|
57678
57678
|
}
|
|
57679
57679
|
/**
|
|
57680
57680
|
* Sets the active Bitcoin network.
|
|
57681
|
-
* @param {keyof AvailableNetworks} active - The Bitcoin network to set as active (e.g., '
|
|
57681
|
+
* @param {keyof AvailableNetworks} active - The Bitcoin network to set as active (e.g., 'bitcoin', 'testnet3', 'signet', 'regtest').
|
|
57682
57682
|
* @throws {MethodError} If no configuration is found for the specified network.
|
|
57683
57683
|
*/
|
|
57684
57684
|
setActiveNetwork(active) {
|
|
@@ -57712,7 +57712,7 @@ init_shim();
|
|
|
57712
57712
|
|
|
57713
57713
|
// ../bitcoin/dist/esm/taproot.js
|
|
57714
57714
|
init_shim();
|
|
57715
|
-
var
|
|
57715
|
+
var tinysecp3 = __toESM(require_dist2(), 1);
|
|
57716
57716
|
|
|
57717
57717
|
// ../keypair/dist/esm/index.js
|
|
57718
57718
|
init_shim();
|
|
@@ -57722,12 +57722,13 @@ init_shim();
|
|
|
57722
57722
|
|
|
57723
57723
|
// ../keypair/dist/esm/public.js
|
|
57724
57724
|
init_shim();
|
|
57725
|
+
var tinysecp2 = __toESM(require_dist2(), 1);
|
|
57725
57726
|
|
|
57726
57727
|
// ../keypair/dist/esm/secret.js
|
|
57727
57728
|
init_shim();
|
|
57728
57729
|
var import_crypto3 = __toESM(require_crypto_browserify(), 1);
|
|
57729
57730
|
var tinysecp = __toESM(require_dist2(), 1);
|
|
57730
|
-
var
|
|
57731
|
+
var Secp256k1SecretKey = class _Secp256k1SecretKey {
|
|
57731
57732
|
/** @type {KeyBytes} The entropy for the secret key as a byte array */
|
|
57732
57733
|
_bytes;
|
|
57733
57734
|
/** @type {bigint} The entropy for the secret key as a bigint */
|
|
@@ -57735,7 +57736,7 @@ var SecretKey = class _SecretKey {
|
|
|
57735
57736
|
/** @type {string} The secret key as a secretKeyMultibase */
|
|
57736
57737
|
_multibase;
|
|
57737
57738
|
/**
|
|
57738
|
-
* Instantiates an instance of
|
|
57739
|
+
* Instantiates an instance of Secp256k1SecretKey.
|
|
57739
57740
|
* @param {Entropy} entropy bytes (Uint8Array) or secret (bigint)
|
|
57740
57741
|
* @throws {SecretKeyError} If entropy is not provided, not a valid 32-byte secret key or not a valid bigint seed
|
|
57741
57742
|
*/
|
|
@@ -57747,10 +57748,10 @@ var SecretKey = class _SecretKey {
|
|
|
57747
57748
|
}
|
|
57748
57749
|
if (isBytes9 && entropy.length === 32) {
|
|
57749
57750
|
this._bytes = entropy;
|
|
57750
|
-
this._seed =
|
|
57751
|
+
this._seed = _Secp256k1SecretKey.toSecret(entropy);
|
|
57751
57752
|
}
|
|
57752
57753
|
if (isSecret && !(entropy < 1n || entropy >= CURVE.n)) {
|
|
57753
|
-
this._bytes =
|
|
57754
|
+
this._bytes = _Secp256k1SecretKey.toBytes(entropy);
|
|
57754
57755
|
this._seed = entropy;
|
|
57755
57756
|
}
|
|
57756
57757
|
if (!this._bytes || this._bytes.length !== 32) {
|
|
@@ -57807,7 +57808,7 @@ var SecretKey = class _SecretKey {
|
|
|
57807
57808
|
}
|
|
57808
57809
|
/**
|
|
57809
57810
|
* Checks if this secret key is equal to another.
|
|
57810
|
-
* @param {
|
|
57811
|
+
* @param {Secp256k1SecretKey} other The other secret key
|
|
57811
57812
|
* @returns {boolean} True if the private keys are equal, false otherwise
|
|
57812
57813
|
*/
|
|
57813
57814
|
equals(other) {
|
|
@@ -57815,7 +57816,7 @@ var SecretKey = class _SecretKey {
|
|
|
57815
57816
|
}
|
|
57816
57817
|
/**
|
|
57817
57818
|
* Computes the public key from the secret key bytes.
|
|
57818
|
-
* @returns {
|
|
57819
|
+
* @returns {CompressedSecp256k1PublicKey} The computed public key
|
|
57819
57820
|
*/
|
|
57820
57821
|
computePublicKey() {
|
|
57821
57822
|
const publicKeyBytes = tinysecp.pointFromScalar(this.bytes, true);
|
|
@@ -57825,7 +57826,7 @@ var SecretKey = class _SecretKey {
|
|
|
57825
57826
|
if (publicKeyBytes.length !== 33) {
|
|
57826
57827
|
throw new SecretKeyError("Invalid compute: public key not compressed format", "COMPUTE_PUBLIC_KEY_ERROR");
|
|
57827
57828
|
}
|
|
57828
|
-
return publicKeyBytes;
|
|
57829
|
+
return new CompressedSecp256k1PublicKey(publicKeyBytes);
|
|
57829
57830
|
}
|
|
57830
57831
|
/**
|
|
57831
57832
|
* Converts the secret key to a JSON object.
|
|
@@ -57847,10 +57848,10 @@ var SecretKey = class _SecretKey {
|
|
|
57847
57848
|
}
|
|
57848
57849
|
/**
|
|
57849
57850
|
* Checks if the public key is a valid secp256k1 point.
|
|
57850
|
-
* @param {PublicKey} pk The public key to validate
|
|
57851
57851
|
* @returns {boolean} True if the public key is valid, false otherwise
|
|
57852
57852
|
*/
|
|
57853
|
-
|
|
57853
|
+
hasValidPublicKey() {
|
|
57854
|
+
const pk = this.computePublicKey();
|
|
57854
57855
|
if (!tinysecp.isPoint(pk.compressed)) {
|
|
57855
57856
|
return false;
|
|
57856
57857
|
}
|
|
@@ -57874,21 +57875,21 @@ var SecretKey = class _SecretKey {
|
|
|
57874
57875
|
return decoded;
|
|
57875
57876
|
}
|
|
57876
57877
|
/**
|
|
57877
|
-
* Creates a
|
|
57878
|
+
* Creates a Secp256k1SecretKey object from a JSON object.
|
|
57878
57879
|
* @param {SecretKeyObject} json The JSON object containing the secret key bytes
|
|
57879
|
-
* @returns {
|
|
57880
|
+
* @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
|
|
57880
57881
|
*/
|
|
57881
57882
|
static fromJSON(json) {
|
|
57882
|
-
return new
|
|
57883
|
+
return new _Secp256k1SecretKey(new Uint8Array(json.bytes));
|
|
57883
57884
|
}
|
|
57884
57885
|
/**
|
|
57885
|
-
* Converts a
|
|
57886
|
-
* @param {KeyBytes} bytes
|
|
57886
|
+
* Converts a Secp256k1SecretKey or KeyBytes to a SchnorrKeyPair.
|
|
57887
|
+
* @param {KeyBytes} bytes The secret key bytes
|
|
57887
57888
|
* @returns {SchnorrKeyPair} The SchnorrKeyPair object containing the public and private keys
|
|
57888
57889
|
* @throws {SecretKeyError} If the secret key is not valid
|
|
57889
57890
|
*/
|
|
57890
57891
|
static toKeyPair(bytes3) {
|
|
57891
|
-
const secretKey = new
|
|
57892
|
+
const secretKey = new _Secp256k1SecretKey(bytes3);
|
|
57892
57893
|
const publicKey2 = secretKey.computePublicKey();
|
|
57893
57894
|
return new SchnorrKeyPair({ publicKey: publicKey2, secretKey });
|
|
57894
57895
|
}
|
|
@@ -57913,14 +57914,14 @@ var SecretKey = class _SecretKey {
|
|
|
57913
57914
|
return new Uint8Array(bytes3);
|
|
57914
57915
|
}
|
|
57915
57916
|
/**
|
|
57916
|
-
* Creates a new
|
|
57917
|
-
* @param {bigint}
|
|
57918
|
-
* @returns {
|
|
57917
|
+
* Creates a new Secp256k1SecretKey object from a bigint secret.
|
|
57918
|
+
* @param {bigint} entropy The secret bigint
|
|
57919
|
+
* @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
|
|
57919
57920
|
*/
|
|
57920
|
-
static
|
|
57921
|
-
const hexsecret =
|
|
57921
|
+
static fromEntropy(entropy) {
|
|
57922
|
+
const hexsecret = entropy.toString(16).padStart(64, "0");
|
|
57922
57923
|
const privateKeyBytes = new Uint8Array(hexsecret.match(/.{2}/g).map((byte) => parseInt(byte, 16)));
|
|
57923
|
-
return new
|
|
57924
|
+
return new _Secp256k1SecretKey(privateKeyBytes);
|
|
57924
57925
|
}
|
|
57925
57926
|
/**
|
|
57926
57927
|
* Generates random secret key bytes.
|
|
@@ -57931,35 +57932,35 @@ var SecretKey = class _SecretKey {
|
|
|
57931
57932
|
return (0, import_crypto3.getRandomValues)(byteArray);
|
|
57932
57933
|
}
|
|
57933
57934
|
/**
|
|
57934
|
-
* Creates a new
|
|
57935
|
-
* @returns {
|
|
57935
|
+
* Creates a new Secp256k1SecretKey from random secret key bytes.
|
|
57936
|
+
* @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
|
|
57936
57937
|
*/
|
|
57937
57938
|
static generate() {
|
|
57938
57939
|
const randomBytes7 = this.random();
|
|
57939
|
-
return new
|
|
57940
|
+
return new _Secp256k1SecretKey(randomBytes7);
|
|
57940
57941
|
}
|
|
57941
57942
|
/**
|
|
57942
57943
|
* Generates a public key from the given secret key bytes.
|
|
57943
57944
|
* @param {KeyBytes} bytes The secret key bytes
|
|
57944
|
-
* @returns {
|
|
57945
|
+
* @returns {CompressedSecp256k1PublicKey} The computed public key bytes
|
|
57945
57946
|
*/
|
|
57946
57947
|
static getPublicKey(bytes3) {
|
|
57947
|
-
return new
|
|
57948
|
+
return new _Secp256k1SecretKey(bytes3).computePublicKey();
|
|
57948
57949
|
}
|
|
57949
57950
|
};
|
|
57950
57951
|
|
|
57951
57952
|
// ../keypair/dist/esm/public.js
|
|
57952
|
-
var
|
|
57953
|
+
var CompressedSecp256k1PublicKey = class _CompressedSecp256k1PublicKey {
|
|
57953
57954
|
/** @type {KeyBytes} The public key bytes */
|
|
57954
57955
|
_bytes;
|
|
57955
57956
|
/** @type {MultibaseObject} The public key as a MultibaseObject */
|
|
57956
57957
|
_multibase = {
|
|
57957
57958
|
prefix: BIP340_PUBLIC_KEY_MULTIBASE_PREFIX,
|
|
57958
57959
|
key: [],
|
|
57959
|
-
|
|
57960
|
+
encoded: ""
|
|
57960
57961
|
};
|
|
57961
57962
|
/**
|
|
57962
|
-
* Creates a
|
|
57963
|
+
* Creates a CompressedSecp256k1PublicKey instance.
|
|
57963
57964
|
* @param {KeyBytes} bytes The public key byte array.
|
|
57964
57965
|
* @throws {PublicKeyError} if the byte length is not 32 (x-only) or 33 (compressed)
|
|
57965
57966
|
*/
|
|
@@ -57967,8 +57968,11 @@ var PublicKey = class _PublicKey {
|
|
|
57967
57968
|
if (bytes3.length !== 33) {
|
|
57968
57969
|
throw new PublicKeyError("Invalid argument: byte length must be 33 (compressed)", "CONSTRUCTOR_ERROR", { bytes: bytes3 });
|
|
57969
57970
|
}
|
|
57971
|
+
if (!tinysecp2.isPoint(bytes3)) {
|
|
57972
|
+
throw new PublicKeyError("Invalid argument: bytes are not a valid secp256k1 compressed point", "CONSTRUCTOR_ERROR", { bytes: bytes3 });
|
|
57973
|
+
}
|
|
57970
57974
|
this._bytes = bytes3;
|
|
57971
|
-
this._multibase.
|
|
57975
|
+
this._multibase.encoded = this.encode();
|
|
57972
57976
|
this._multibase.key = [...this._multibase.prefix, ...this.compressed];
|
|
57973
57977
|
}
|
|
57974
57978
|
/**
|
|
@@ -57988,13 +57992,30 @@ var PublicKey = class _PublicKey {
|
|
|
57988
57992
|
return uncompressed;
|
|
57989
57993
|
}
|
|
57990
57994
|
/**
|
|
57991
|
-
*
|
|
57992
|
-
|
|
57995
|
+
* X-only (32-byte) view of the public key per BIP-340.
|
|
57996
|
+
*/
|
|
57997
|
+
get xOnly() {
|
|
57998
|
+
return this._bytes.slice(1);
|
|
57999
|
+
}
|
|
58000
|
+
/**
|
|
58001
|
+
* Parity of the SEC compressed public key.
|
|
58002
|
+
* @returns {0x02 | 0x03} The parity byte (0x02 if even, 0x03 if odd).
|
|
58003
|
+
* @throws {PublicKeyError} If the parity byte is not 0x02 or 0x03.
|
|
57993
58004
|
*/
|
|
57994
58005
|
get parity() {
|
|
57995
|
-
const parity = this.
|
|
58006
|
+
const parity = this._bytes[0];
|
|
58007
|
+
if (![2, 3].includes(parity)) {
|
|
58008
|
+
throw new PublicKeyError("Invalid state: parity byte must be 2 or 3", "PARITY_ERROR", { parity });
|
|
58009
|
+
}
|
|
57996
58010
|
return parity;
|
|
57997
58011
|
}
|
|
58012
|
+
/**
|
|
58013
|
+
* Whether the SEC compressed public key has even Y.
|
|
58014
|
+
* @returns {boolean} True if the public key has even Y.
|
|
58015
|
+
*/
|
|
58016
|
+
get isEven() {
|
|
58017
|
+
return this._bytes[0] === 2;
|
|
58018
|
+
}
|
|
57998
58019
|
/**
|
|
57999
58020
|
* Get the x-coordinate of the public key.
|
|
58000
58021
|
* @returns {Uint8Array} The 32-byte x-coordinate of the public key.
|
|
@@ -58037,6 +58058,13 @@ var PublicKey = class _PublicKey {
|
|
|
58037
58058
|
y: this.y
|
|
58038
58059
|
};
|
|
58039
58060
|
}
|
|
58061
|
+
/**
|
|
58062
|
+
* Returns the BIP-340 (x-only) representation of this key.
|
|
58063
|
+
* @returns {KeyBytes} The BIP-340 (x-only) representation of the public key.
|
|
58064
|
+
*/
|
|
58065
|
+
bip340() {
|
|
58066
|
+
return this.xOnly;
|
|
58067
|
+
}
|
|
58040
58068
|
/**
|
|
58041
58069
|
* Returns the point of the public key.
|
|
58042
58070
|
* @param {Hex} pk The public key in hex (Uint8Array or string) format.
|
|
@@ -58045,11 +58073,11 @@ var PublicKey = class _PublicKey {
|
|
|
58045
58073
|
*/
|
|
58046
58074
|
static point(pk) {
|
|
58047
58075
|
if (typeof pk === "string" && /^[0-9a-fA-F]+$/.test(pk)) {
|
|
58048
|
-
const publicKey2 = new
|
|
58076
|
+
const publicKey2 = new _CompressedSecp256k1PublicKey(import_buffer.Buffer.fromHex(pk));
|
|
58049
58077
|
return publicKey2.point;
|
|
58050
58078
|
}
|
|
58051
58079
|
if (pk instanceof Uint8Array || ArrayBuffer.isView(pk)) {
|
|
58052
|
-
const publicKey2 = new
|
|
58080
|
+
const publicKey2 = new _CompressedSecp256k1PublicKey(pk);
|
|
58053
58081
|
return publicKey2.point;
|
|
58054
58082
|
}
|
|
58055
58083
|
throw new PublicKeyError("Invalid publicKey: must be a hex string or byte array", "POINT_ERROR", { publicKey: pk });
|
|
@@ -58059,7 +58087,7 @@ var PublicKey = class _PublicKey {
|
|
|
58059
58087
|
* @returns {KeyBytes} The decoded public key: prefix and public key bytes
|
|
58060
58088
|
*/
|
|
58061
58089
|
decode() {
|
|
58062
|
-
const decoded = base58btc.decode(this.multibase.
|
|
58090
|
+
const decoded = base58btc.decode(this.multibase.encoded);
|
|
58063
58091
|
if (decoded.length !== 35) {
|
|
58064
58092
|
throw new PublicKeyError("Invalid argument: must be 35 byte publicKeyMultibase", "DECODE_MULTIBASE_ERROR");
|
|
58065
58093
|
}
|
|
@@ -58085,15 +58113,15 @@ var PublicKey = class _PublicKey {
|
|
|
58085
58113
|
}
|
|
58086
58114
|
/**
|
|
58087
58115
|
* Compares this public key to another public key.
|
|
58088
|
-
* @param {
|
|
58116
|
+
* @param {CompressedSecp256k1PublicKey} other The other public key to compare
|
|
58089
58117
|
* @returns {boolean} True if the public keys are equal, false otherwise.
|
|
58090
58118
|
*/
|
|
58091
58119
|
equals(other) {
|
|
58092
58120
|
return this.hex === other.hex;
|
|
58093
58121
|
}
|
|
58094
58122
|
/**
|
|
58095
|
-
* JSON representation of a
|
|
58096
|
-
* @returns {PublicKeyObject} The
|
|
58123
|
+
* JSON representation of a CompressedSecp256k1PublicKey object.
|
|
58124
|
+
* @returns {PublicKeyObject} The CompressedSecp256k1PublicKey as a JSON object.
|
|
58097
58125
|
*/
|
|
58098
58126
|
json() {
|
|
58099
58127
|
return {
|
|
@@ -58107,26 +58135,26 @@ var PublicKey = class _PublicKey {
|
|
|
58107
58135
|
};
|
|
58108
58136
|
}
|
|
58109
58137
|
/**
|
|
58110
|
-
* Creates a
|
|
58111
|
-
* @param {PublicKeyObject} json The JSON object to initialize the
|
|
58112
|
-
* @returns {
|
|
58138
|
+
* Creates a CompressedSecp256k1PublicKey object from a JSON representation.
|
|
58139
|
+
* @param {PublicKeyObject} json The JSON object to initialize the CompressedSecp256k1PublicKey.
|
|
58140
|
+
* @returns {CompressedSecp256k1PublicKey} The initialized CompressedSecp256k1PublicKey object.
|
|
58113
58141
|
*/
|
|
58114
58142
|
static fromJSON(json) {
|
|
58115
58143
|
json.x.unshift(json.parity);
|
|
58116
|
-
return new
|
|
58144
|
+
return new _CompressedSecp256k1PublicKey(json.x.toUint8Array());
|
|
58117
58145
|
}
|
|
58118
58146
|
/**
|
|
58119
|
-
* Computes the deterministic public key for a given
|
|
58120
|
-
* @param {
|
|
58121
|
-
* @returns {
|
|
58147
|
+
* Computes the deterministic public key for a given secret key.
|
|
58148
|
+
* @param {Secp256k1SecretKey | KeyBytes} sk The Secp256k1SecretKey object or the secret key bytes
|
|
58149
|
+
* @returns {CompressedSecp256k1PublicKey} A new CompressedSecp256k1PublicKey object
|
|
58122
58150
|
*/
|
|
58123
58151
|
static fromSecretKey(sk) {
|
|
58124
|
-
const bytes3 = sk instanceof
|
|
58152
|
+
const bytes3 = sk instanceof Secp256k1SecretKey ? sk.bytes : sk;
|
|
58125
58153
|
if (bytes3.length !== 32) {
|
|
58126
|
-
throw new PublicKeyError("Invalid arg: must be 32 byte
|
|
58154
|
+
throw new PublicKeyError("Invalid arg: must be 32 byte secret key", "FROM_SECRET_KEY_ERROR");
|
|
58127
58155
|
}
|
|
58128
|
-
const
|
|
58129
|
-
return
|
|
58156
|
+
const secret = sk instanceof Secp256k1SecretKey ? sk : new Secp256k1SecretKey(sk);
|
|
58157
|
+
return secret.computePublicKey();
|
|
58130
58158
|
}
|
|
58131
58159
|
/**
|
|
58132
58160
|
* Computes modular exponentiation: (base^exp) % mod.
|
|
@@ -58174,23 +58202,11 @@ var PublicKey = class _PublicKey {
|
|
|
58174
58202
|
const yBytes = import_buffer.Buffer.fromHex(y.toString(16).padStart(64, "0"));
|
|
58175
58203
|
return new Uint8Array(import_buffer.Buffer.concat([import_buffer.Buffer.from([4]), import_buffer.Buffer.from(this.x), yBytes]));
|
|
58176
58204
|
}
|
|
58177
|
-
/**
|
|
58178
|
-
* Static version of liftX method.
|
|
58179
|
-
* @param {KeyBytes} x The 32-byte x-coordinate to lift.
|
|
58180
|
-
* @returns {Uint8Array} The 65-byte uncompressed public key (0x04, x, y).
|
|
58181
|
-
*/
|
|
58182
|
-
static xOnly(x) {
|
|
58183
|
-
if (x.length !== 32) {
|
|
58184
|
-
throw new PublicKeyError("Invalid argument: x-coordinate length must be 32 bytes", "LIFT_X_ERROR");
|
|
58185
|
-
}
|
|
58186
|
-
const publicKey2 = new _PublicKey(x);
|
|
58187
|
-
return publicKey2.x;
|
|
58188
|
-
}
|
|
58189
58205
|
};
|
|
58190
58206
|
|
|
58191
58207
|
// ../keypair/dist/esm/pair.js
|
|
58192
58208
|
var SchnorrKeyPair = class _SchnorrKeyPair {
|
|
58193
|
-
/** @type {
|
|
58209
|
+
/** @type {Secp256k1SecretKey} The secret key object */
|
|
58194
58210
|
_secretKey;
|
|
58195
58211
|
_publicKey;
|
|
58196
58212
|
/** @type {string} The public key in multibase format */
|
|
@@ -58199,31 +58215,35 @@ var SchnorrKeyPair = class _SchnorrKeyPair {
|
|
|
58199
58215
|
_secretKeyMultibase;
|
|
58200
58216
|
/**
|
|
58201
58217
|
* Creates an instance of Keys. Must provide a at least a secret key.
|
|
58202
|
-
* Can optionally provide both a
|
|
58203
|
-
* @param {
|
|
58218
|
+
* Can optionally provide both a secret and public key, but must be a valid pair.
|
|
58219
|
+
* @param {SchnorrKeyPairParams} params The parameters to initialize the Keys object.
|
|
58220
|
+
* @param {CompressedSecp256k1PublicKey | KeyBytes} params.publicKey The public key object or bytes
|
|
58221
|
+
* @param {Secp256k1SecretKey | KeyBytes} [params.secret] The secret key object or bytes
|
|
58222
|
+
* @throws {KeyPairError} If neither a public key or secret key is provided.
|
|
58223
|
+
* @throws {KeyPairError} If the public key is not a valid pair with the secret key.
|
|
58204
58224
|
*/
|
|
58205
|
-
constructor(
|
|
58206
|
-
if (!
|
|
58225
|
+
constructor(params = {}) {
|
|
58226
|
+
if (!params.publicKey && !params.secretKey) {
|
|
58207
58227
|
throw new KeyPairError("Argument missing: must at least provide a publicKey", "CONSTRUCTOR_ERROR");
|
|
58208
58228
|
}
|
|
58209
|
-
if (secretKey instanceof Uint8Array) {
|
|
58210
|
-
this._secretKey = new
|
|
58211
|
-
} else if (secretKey instanceof
|
|
58212
|
-
this._secretKey = secretKey;
|
|
58229
|
+
if (params.secretKey instanceof Uint8Array) {
|
|
58230
|
+
this._secretKey = new Secp256k1SecretKey(params.secretKey);
|
|
58231
|
+
} else if (params.secretKey instanceof Secp256k1SecretKey) {
|
|
58232
|
+
this._secretKey = params.secretKey;
|
|
58213
58233
|
}
|
|
58214
|
-
if (
|
|
58215
|
-
this._publicKey =
|
|
58216
|
-
} else if (
|
|
58217
|
-
this._publicKey = new
|
|
58234
|
+
if (params.publicKey instanceof CompressedSecp256k1PublicKey) {
|
|
58235
|
+
this._publicKey = params.publicKey;
|
|
58236
|
+
} else if (params.publicKey instanceof Uint8Array) {
|
|
58237
|
+
this._publicKey = new CompressedSecp256k1PublicKey(params.publicKey);
|
|
58218
58238
|
} else {
|
|
58219
|
-
this._publicKey =
|
|
58239
|
+
this._publicKey = this._secretKey.computePublicKey();
|
|
58220
58240
|
}
|
|
58221
|
-
this._publicKeyMultibase = this._publicKey.multibase.
|
|
58241
|
+
this._publicKeyMultibase = this._publicKey.multibase.encoded;
|
|
58222
58242
|
this._secretKeyMultibase = this._secretKey ? this._secretKey.multibase : "";
|
|
58223
58243
|
}
|
|
58224
58244
|
/**
|
|
58225
|
-
* Get the
|
|
58226
|
-
* @returns {
|
|
58245
|
+
* Get the Secp256k1SecretKey.
|
|
58246
|
+
* @returns {Secp256k1SecretKey} The Secp256k1SecretKey object
|
|
58227
58247
|
* @throws {KeyPairError} If the secret key is not available
|
|
58228
58248
|
*/
|
|
58229
58249
|
get secretKey() {
|
|
@@ -58233,33 +58253,38 @@ var SchnorrKeyPair = class _SchnorrKeyPair {
|
|
|
58233
58253
|
if (!this._secretKey.isValid()) {
|
|
58234
58254
|
throw new KeyPairError("Secret key is not valid", "SECRET_KEY_ERROR");
|
|
58235
58255
|
}
|
|
58236
|
-
const
|
|
58237
|
-
return
|
|
58256
|
+
const secret = this._secretKey;
|
|
58257
|
+
return secret;
|
|
58238
58258
|
}
|
|
58239
58259
|
/**
|
|
58240
|
-
* Set the
|
|
58241
|
-
* @param {
|
|
58260
|
+
* Set the CompressedSecp256k1PublicKey.
|
|
58261
|
+
* @param {CompressedSecp256k1PublicKey} publicKey The CompressedSecp256k1PublicKey object
|
|
58242
58262
|
* @throws {KeyPairError} If the public key is not a valid pair with the secret key.
|
|
58243
58263
|
*/
|
|
58244
58264
|
set publicKey(publicKey2) {
|
|
58245
|
-
if (this.secretKey
|
|
58246
|
-
|
|
58265
|
+
if (this.secretKey) {
|
|
58266
|
+
if (!this.secretKey.hasValidPublicKey()) {
|
|
58267
|
+
throw new KeyPairError("Secret key is not valid", "SECRET_KEY_ERROR");
|
|
58268
|
+
}
|
|
58269
|
+
const cPk = this.secretKey.computePublicKey();
|
|
58270
|
+
if (!publicKey2.equals(cPk))
|
|
58271
|
+
throw new KeyPairError("Public key is not a valid pair with the secret key", "PUBLIC_KEY_ERROR");
|
|
58247
58272
|
}
|
|
58248
58273
|
this._publicKey = publicKey2;
|
|
58249
|
-
this._publicKeyMultibase = publicKey2.multibase.
|
|
58274
|
+
this._publicKeyMultibase = publicKey2.multibase.encoded;
|
|
58250
58275
|
this._secretKeyMultibase = this._secretKey ? this._secretKey.multibase : "";
|
|
58251
58276
|
}
|
|
58252
58277
|
/**
|
|
58253
|
-
* Get the
|
|
58254
|
-
* @returns {
|
|
58278
|
+
* Get the CompressedSecp256k1PublicKey.
|
|
58279
|
+
* @returns {CompressedSecp256k1PublicKey} The CompressedSecp256k1PublicKey object
|
|
58255
58280
|
*/
|
|
58256
58281
|
get publicKey() {
|
|
58257
58282
|
const publicKey2 = this._publicKey;
|
|
58258
58283
|
return publicKey2;
|
|
58259
58284
|
}
|
|
58260
58285
|
/**
|
|
58261
|
-
* Get the
|
|
58262
|
-
* @returns {
|
|
58286
|
+
* Get the raw bytes of each key in the SchnorrKeyPair.
|
|
58287
|
+
* @returns {RawSchnorrKeyPair} JSON object with the SchnorrKeyPair raw bytes.
|
|
58263
58288
|
*/
|
|
58264
58289
|
get raw() {
|
|
58265
58290
|
return {
|
|
@@ -58269,7 +58294,7 @@ var SchnorrKeyPair = class _SchnorrKeyPair {
|
|
|
58269
58294
|
}
|
|
58270
58295
|
/**
|
|
58271
58296
|
* Get the Keys in multibase format.
|
|
58272
|
-
* @returns {MultibaseKeys} The
|
|
58297
|
+
* @returns {MultibaseKeys} The Secp256k1SecretKey in multibase format
|
|
58273
58298
|
*/
|
|
58274
58299
|
get multibase() {
|
|
58275
58300
|
return {
|
|
@@ -58293,37 +58318,40 @@ var SchnorrKeyPair = class _SchnorrKeyPair {
|
|
|
58293
58318
|
* @returns {SchnorrKeyPair} The initialized Keys object.
|
|
58294
58319
|
*/
|
|
58295
58320
|
static fromJSON(keys) {
|
|
58296
|
-
|
|
58297
|
-
|
|
58298
|
-
|
|
58321
|
+
return new _SchnorrKeyPair({
|
|
58322
|
+
secretKey: Secp256k1SecretKey.fromJSON(keys.secretKey),
|
|
58323
|
+
publicKey: CompressedSecp256k1PublicKey.fromJSON(keys.publicKey)
|
|
58324
|
+
});
|
|
58299
58325
|
}
|
|
58300
58326
|
/**
|
|
58301
|
-
* Static method creates a new SchnorrKeyPair from a
|
|
58302
|
-
* @param {
|
|
58327
|
+
* Static method creates a new SchnorrKeyPair from a Secp256k1SecretKey object or secret key bytes.
|
|
58328
|
+
* @param {Secp256k1SecretKey | KeyBytes} data The secret key bytes
|
|
58303
58329
|
* @returns {SchnorrKeyPair} A new SchnorrKeyPair object
|
|
58304
58330
|
*/
|
|
58305
58331
|
static fromPrivateKey(data) {
|
|
58306
|
-
const bytes3 = data instanceof
|
|
58332
|
+
const bytes3 = data instanceof Secp256k1SecretKey ? data.bytes : data;
|
|
58307
58333
|
if (bytes3.length !== 32) {
|
|
58308
58334
|
throw new KeyPairError("Invalid arg: must be 32 byte secret key", "FROM_PRIVATE_KEY_ERROR");
|
|
58309
58335
|
}
|
|
58310
|
-
const
|
|
58311
|
-
|
|
58312
|
-
|
|
58336
|
+
const secret = data instanceof Uint8Array ? new Secp256k1SecretKey(data) : data;
|
|
58337
|
+
return new _SchnorrKeyPair({
|
|
58338
|
+
secretKey: data instanceof Uint8Array ? new Secp256k1SecretKey(data) : data,
|
|
58339
|
+
publicKey: secret.computePublicKey()
|
|
58340
|
+
});
|
|
58313
58341
|
}
|
|
58314
58342
|
/**
|
|
58315
|
-
* Static method creates a new Keys (
|
|
58316
|
-
* @param {bigint}
|
|
58317
|
-
* @returns {
|
|
58343
|
+
* Static method creates a new Keys (Secp256k1SecretKey/CompressedSecp256k1PublicKey) from bigint entropy.
|
|
58344
|
+
* @param {bigint} entropy The entropy in bigint form
|
|
58345
|
+
* @returns {SchnorrKeyPair} A new SchnorrKeyPair object
|
|
58318
58346
|
*/
|
|
58319
|
-
static
|
|
58320
|
-
const secretKey =
|
|
58347
|
+
static fromEntropy(entropy) {
|
|
58348
|
+
const secretKey = Secp256k1SecretKey.fromEntropy(entropy);
|
|
58321
58349
|
const publicKey2 = secretKey.computePublicKey();
|
|
58322
58350
|
return new _SchnorrKeyPair({ secretKey, publicKey: publicKey2 });
|
|
58323
58351
|
}
|
|
58324
58352
|
/**
|
|
58325
58353
|
* Converts key bytes to a hex string.
|
|
58326
|
-
* @param {KeyBytes} keyBytes The key bytes (
|
|
58354
|
+
* @param {KeyBytes} keyBytes The key bytes (secret or public).
|
|
58327
58355
|
* @returns {Hex} The key bytes as a hex string.
|
|
58328
58356
|
*/
|
|
58329
58357
|
static toHex(keyBytes) {
|
|
@@ -58331,18 +58359,18 @@ var SchnorrKeyPair = class _SchnorrKeyPair {
|
|
|
58331
58359
|
}
|
|
58332
58360
|
/**
|
|
58333
58361
|
* Compares two Keys objects for equality.
|
|
58334
|
-
* @param {SchnorrKeyPair}
|
|
58335
|
-
* @param {SchnorrKeyPair}
|
|
58362
|
+
* @param {SchnorrKeyPair} kp The main keys.
|
|
58363
|
+
* @param {SchnorrKeyPair} otherKp The other keys to compare.
|
|
58336
58364
|
* @returns {boolean} True if the public key and secret key are equal, false otherwise.
|
|
58337
58365
|
*/
|
|
58338
|
-
static equals(
|
|
58339
|
-
const pk =
|
|
58340
|
-
const otherPk =
|
|
58366
|
+
static equals(kp, otherKp) {
|
|
58367
|
+
const pk = kp.publicKey;
|
|
58368
|
+
const otherPk = otherKp.publicKey;
|
|
58341
58369
|
if (pk && otherPk) {
|
|
58342
58370
|
return pk.hex === otherPk.hex;
|
|
58343
58371
|
}
|
|
58344
|
-
const sk =
|
|
58345
|
-
const otherSk =
|
|
58372
|
+
const sk = kp.secretKey;
|
|
58373
|
+
const otherSk = otherKp.secretKey;
|
|
58346
58374
|
if (sk && otherSk) {
|
|
58347
58375
|
return sk.hex === otherSk.hex;
|
|
58348
58376
|
}
|
|
@@ -58350,16 +58378,19 @@ var SchnorrKeyPair = class _SchnorrKeyPair {
|
|
|
58350
58378
|
}
|
|
58351
58379
|
/**
|
|
58352
58380
|
* Static method to generate a new random SchnorrKeyPair instance.
|
|
58353
|
-
* @returns {SchnorrKeyPair} A new
|
|
58381
|
+
* @returns {SchnorrKeyPair} A new Secp256k1SecretKey object.
|
|
58354
58382
|
*/
|
|
58355
58383
|
static generate() {
|
|
58356
|
-
const
|
|
58357
|
-
const secretKey = new
|
|
58384
|
+
const sk = Secp256k1SecretKey.random();
|
|
58385
|
+
const secretKey = new Secp256k1SecretKey(sk);
|
|
58358
58386
|
const publicKey2 = secretKey.computePublicKey();
|
|
58359
58387
|
return new _SchnorrKeyPair({ secretKey, publicKey: publicKey2 });
|
|
58360
58388
|
}
|
|
58361
58389
|
};
|
|
58362
58390
|
|
|
58391
|
+
// ../keypair/dist/esm/types.js
|
|
58392
|
+
init_shim();
|
|
58393
|
+
|
|
58363
58394
|
// src/utils/appendix.ts
|
|
58364
58395
|
init_shim();
|
|
58365
58396
|
|
|
@@ -65680,7 +65711,7 @@ function twistedEdwards(curveDef) {
|
|
|
65680
65711
|
return n3 === _0n6 ? n3 : assertInRange(n3, CURVE_ORDER);
|
|
65681
65712
|
}
|
|
65682
65713
|
const pointPrecomputes2 = /* @__PURE__ */ new Map();
|
|
65683
|
-
function
|
|
65714
|
+
function isPoint4(other) {
|
|
65684
65715
|
if (!(other instanceof Point4))
|
|
65685
65716
|
throw new Error("ExtendedPoint expected");
|
|
65686
65717
|
}
|
|
@@ -65745,7 +65776,7 @@ function twistedEdwards(curveDef) {
|
|
|
65745
65776
|
}
|
|
65746
65777
|
// Compare one point to another.
|
|
65747
65778
|
equals(other) {
|
|
65748
|
-
|
|
65779
|
+
isPoint4(other);
|
|
65749
65780
|
const { ex: X1, ey: Y1, ez: Z1 } = this;
|
|
65750
65781
|
const { ex: X2, ey: Y2, ez: Z2 } = other;
|
|
65751
65782
|
const X1Z2 = modP(X1 * Z2);
|
|
@@ -65785,7 +65816,7 @@ function twistedEdwards(curveDef) {
|
|
|
65785
65816
|
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
|
|
65786
65817
|
// Cost: 9M + 1*a + 1*d + 7add.
|
|
65787
65818
|
add(other) {
|
|
65788
|
-
|
|
65819
|
+
isPoint4(other);
|
|
65789
65820
|
const { a: a3, d: d2 } = CURVE2;
|
|
65790
65821
|
const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;
|
|
65791
65822
|
const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other;
|
|
@@ -86841,10 +86872,10 @@ var __KeyTypeValues;
|
|
|
86841
86872
|
return enumeration(__KeyTypeValues);
|
|
86842
86873
|
};
|
|
86843
86874
|
})(KeyType || (KeyType = {}));
|
|
86844
|
-
var
|
|
86845
|
-
(function(
|
|
86875
|
+
var PublicKey;
|
|
86876
|
+
(function(PublicKey3) {
|
|
86846
86877
|
let _codec;
|
|
86847
|
-
|
|
86878
|
+
PublicKey3.codec = () => {
|
|
86848
86879
|
if (_codec == null) {
|
|
86849
86880
|
_codec = message((obj, w, opts = {}) => {
|
|
86850
86881
|
if (opts.lengthDelimited !== false) {
|
|
@@ -86886,13 +86917,13 @@ var PublicKey2;
|
|
|
86886
86917
|
}
|
|
86887
86918
|
return _codec;
|
|
86888
86919
|
};
|
|
86889
|
-
|
|
86890
|
-
return encodeMessage(obj,
|
|
86920
|
+
PublicKey3.encode = (obj) => {
|
|
86921
|
+
return encodeMessage(obj, PublicKey3.codec());
|
|
86891
86922
|
};
|
|
86892
|
-
|
|
86893
|
-
return decodeMessage(buf2,
|
|
86923
|
+
PublicKey3.decode = (buf2, opts) => {
|
|
86924
|
+
return decodeMessage(buf2, PublicKey3.codec(), opts);
|
|
86894
86925
|
};
|
|
86895
|
-
})(
|
|
86926
|
+
})(PublicKey || (PublicKey = {}));
|
|
86896
86927
|
var PrivateKey;
|
|
86897
86928
|
(function(PrivateKey3) {
|
|
86898
86929
|
let _codec;
|
|
@@ -87143,7 +87174,7 @@ function pkixToRSAPublicKey(bytes3, digest2) {
|
|
|
87143
87174
|
function pkixMessageToRSAPublicKey(message2, bytes3, digest2) {
|
|
87144
87175
|
const jwk = pkixMessageToJwk(message2);
|
|
87145
87176
|
if (digest2 == null) {
|
|
87146
|
-
const hash2 = sha2562(
|
|
87177
|
+
const hash2 = sha2562(PublicKey.encode({
|
|
87147
87178
|
Type: KeyType.RSA,
|
|
87148
87179
|
Data: bytes3
|
|
87149
87180
|
}));
|
|
@@ -87156,7 +87187,7 @@ function jwkToRSAPrivateKey(jwk) {
|
|
|
87156
87187
|
throw new InvalidParametersError("Key size is too large");
|
|
87157
87188
|
}
|
|
87158
87189
|
const keys = jwkToJWKKeyPair(jwk);
|
|
87159
|
-
const hash2 = sha2562(
|
|
87190
|
+
const hash2 = sha2562(PublicKey.encode({
|
|
87160
87191
|
Type: KeyType.RSA,
|
|
87161
87192
|
Data: jwkToPkix(keys.publicKey)
|
|
87162
87193
|
}));
|
|
@@ -87168,7 +87199,7 @@ async function generateRSAKeyPair(bits) {
|
|
|
87168
87199
|
throw new InvalidParametersError("Key size is too large");
|
|
87169
87200
|
}
|
|
87170
87201
|
const keys = await generateRSAKey(bits);
|
|
87171
|
-
const hash2 = sha2562(
|
|
87202
|
+
const hash2 = sha2562(PublicKey.encode({
|
|
87172
87203
|
Type: KeyType.RSA,
|
|
87173
87204
|
Data: jwkToPkix(keys.publicKey)
|
|
87174
87205
|
}));
|
|
@@ -88659,7 +88690,7 @@ async function generateKeyPair(type, bits) {
|
|
|
88659
88690
|
throw new UnsupportedKeyTypeError();
|
|
88660
88691
|
}
|
|
88661
88692
|
function publicKeyFromProtobuf(buf2, digest2) {
|
|
88662
|
-
const { Type: Type2, Data } =
|
|
88693
|
+
const { Type: Type2, Data } = PublicKey.decode(buf2);
|
|
88663
88694
|
const data = Data ?? new Uint8Array();
|
|
88664
88695
|
switch (Type2) {
|
|
88665
88696
|
case KeyType.RSA:
|
|
@@ -88675,7 +88706,7 @@ function publicKeyFromProtobuf(buf2, digest2) {
|
|
|
88675
88706
|
}
|
|
88676
88707
|
}
|
|
88677
88708
|
function publicKeyFromMultihash(digest2) {
|
|
88678
|
-
const { Type: Type2, Data } =
|
|
88709
|
+
const { Type: Type2, Data } = PublicKey.decode(digest2.digest);
|
|
88679
88710
|
const data = Data ?? new Uint8Array();
|
|
88680
88711
|
switch (Type2) {
|
|
88681
88712
|
case KeyType.Ed25519:
|
|
@@ -88689,7 +88720,7 @@ function publicKeyFromMultihash(digest2) {
|
|
|
88689
88720
|
}
|
|
88690
88721
|
}
|
|
88691
88722
|
function publicKeyToProtobuf(key) {
|
|
88692
|
-
return
|
|
88723
|
+
return PublicKey.encode({
|
|
88693
88724
|
Type: KeyType[key.type],
|
|
88694
88725
|
Data: key.raw
|
|
88695
88726
|
});
|
|
@@ -142574,7 +142605,7 @@ var PemData = class _PemData extends AsnData {
|
|
|
142574
142605
|
}
|
|
142575
142606
|
}
|
|
142576
142607
|
};
|
|
142577
|
-
var
|
|
142608
|
+
var PublicKey2 = class _PublicKey extends PemData {
|
|
142578
142609
|
static async create(data, crypto6 = cryptoProvider.get()) {
|
|
142579
142610
|
if (data instanceof _PublicKey) {
|
|
142580
142611
|
return data;
|
|
@@ -142690,7 +142721,7 @@ var AuthorityKeyIdentifierExtension = class _AuthorityKeyIdentifierExtension ext
|
|
|
142690
142721
|
if ("name" in param && "serialNumber" in param) {
|
|
142691
142722
|
return new _AuthorityKeyIdentifierExtension(param, critical);
|
|
142692
142723
|
}
|
|
142693
|
-
const key = await
|
|
142724
|
+
const key = await PublicKey2.create(param, crypto6);
|
|
142694
142725
|
const id = await key.getKeyIdentifier(crypto6);
|
|
142695
142726
|
return new _AuthorityKeyIdentifierExtension(import_pvtsutils6.Convert.ToHex(id), critical);
|
|
142696
142727
|
}
|
|
@@ -142830,7 +142861,7 @@ var KeyUsagesExtension = class extends Extension2 {
|
|
|
142830
142861
|
KeyUsagesExtension.NAME = "Key Usages";
|
|
142831
142862
|
var SubjectKeyIdentifierExtension = class _SubjectKeyIdentifierExtension extends Extension2 {
|
|
142832
142863
|
static async create(publicKey2, critical = false, crypto6 = cryptoProvider.get()) {
|
|
142833
|
-
const key = await
|
|
142864
|
+
const key = await PublicKey2.create(publicKey2, crypto6);
|
|
142834
142865
|
const id = await key.getKeyIdentifier(crypto6);
|
|
142835
142866
|
return new _SubjectKeyIdentifierExtension(import_pvtsutils6.Convert.ToHex(id), critical);
|
|
142836
142867
|
}
|
|
@@ -143472,7 +143503,7 @@ var Pkcs10CertificateRequest = class extends PemData {
|
|
|
143472
143503
|
}
|
|
143473
143504
|
get publicKey() {
|
|
143474
143505
|
if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_publicKey, "f")) {
|
|
143475
|
-
__classPrivateFieldSet(this, _Pkcs10CertificateRequest_publicKey, new
|
|
143506
|
+
__classPrivateFieldSet(this, _Pkcs10CertificateRequest_publicKey, new PublicKey2(this.asn.certificationRequestInfo.subjectPKInfo), "f");
|
|
143476
143507
|
}
|
|
143477
143508
|
return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_publicKey, "f");
|
|
143478
143509
|
}
|
|
@@ -143594,7 +143625,7 @@ var _X509Certificate_publicKey;
|
|
|
143594
143625
|
var X509Certificate = class extends PemData {
|
|
143595
143626
|
get publicKey() {
|
|
143596
143627
|
if (!__classPrivateFieldGet(this, _X509Certificate_publicKey, "f")) {
|
|
143597
|
-
__classPrivateFieldSet(this, _X509Certificate_publicKey, new
|
|
143628
|
+
__classPrivateFieldSet(this, _X509Certificate_publicKey, new PublicKey2(this.asn.tbsCertificate.subjectPublicKeyInfo), "f");
|
|
143598
143629
|
}
|
|
143599
143630
|
return __classPrivateFieldGet(this, _X509Certificate_publicKey, "f");
|
|
143600
143631
|
}
|
|
@@ -143734,11 +143765,11 @@ var X509Certificate = class extends PemData {
|
|
|
143734
143765
|
} else if ("publicKey" in paramsKey) {
|
|
143735
143766
|
keyAlgorithm = { ...paramsKey.publicKey.algorithm, ...this.signatureAlgorithm };
|
|
143736
143767
|
publicKey2 = await paramsKey.publicKey.export(keyAlgorithm, ["verify"], crypto6);
|
|
143737
|
-
} else if (paramsKey instanceof
|
|
143768
|
+
} else if (paramsKey instanceof PublicKey2) {
|
|
143738
143769
|
keyAlgorithm = { ...paramsKey.algorithm, ...this.signatureAlgorithm };
|
|
143739
143770
|
publicKey2 = await paramsKey.export(keyAlgorithm, ["verify"], crypto6);
|
|
143740
143771
|
} else if (import_pvtsutils6.BufferSourceConverter.isBufferSource(paramsKey)) {
|
|
143741
|
-
const key = new
|
|
143772
|
+
const key = new PublicKey2(paramsKey);
|
|
143742
143773
|
keyAlgorithm = { ...key.algorithm, ...this.signatureAlgorithm };
|
|
143743
143774
|
publicKey2 = await key.export(keyAlgorithm, ["verify"], crypto6);
|
|
143744
143775
|
} else {
|
|
@@ -143867,7 +143898,7 @@ var X509CertificateGenerator = class {
|
|
|
143867
143898
|
static async create(params, crypto6 = cryptoProvider.get()) {
|
|
143868
143899
|
var _a3;
|
|
143869
143900
|
let spki;
|
|
143870
|
-
if (params.publicKey instanceof
|
|
143901
|
+
if (params.publicKey instanceof PublicKey2) {
|
|
143871
143902
|
spki = params.publicKey.rawData;
|
|
143872
143903
|
} else if ("publicKey" in params.publicKey) {
|
|
143873
143904
|
spki = params.publicKey.publicKey.rawData;
|
|
@@ -145174,7 +145205,7 @@ var Appendix = class _Appendix {
|
|
|
145174
145205
|
return verificationMethods;
|
|
145175
145206
|
}
|
|
145176
145207
|
/**
|
|
145177
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#derive-root-capability-from-
|
|
145208
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/#derive-root-capability-from-didbtcr2-identifier | 9.4.1 Derive Root Capability from did:btcr2 Identifier }.
|
|
145178
145209
|
*
|
|
145179
145210
|
* The Derive Root Capability algorithm deterministically generates a ZCAP-LD root capability from a given did:btcr2
|
|
145180
145211
|
* identifier. Each root capability is unique to the identifier. This root capability is defined and understood by the
|
|
@@ -145182,7 +145213,7 @@ var Appendix = class _Appendix {
|
|
|
145182
145213
|
* document. It takes in a did:btcr2 identifier and returns a rootCapability object. It returns the root capability.
|
|
145183
145214
|
*
|
|
145184
145215
|
* @param {string} identifier The did-btcr2 identifier to derive the root capability from
|
|
145185
|
-
* @returns {
|
|
145216
|
+
* @returns {RootCapability} The root capability object
|
|
145186
145217
|
* @example Root capability for updating the DID document for
|
|
145187
145218
|
* did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u
|
|
145188
145219
|
* ```
|
|
@@ -145210,7 +145241,7 @@ var Appendix = class _Appendix {
|
|
|
145210
145241
|
* capability object.
|
|
145211
145242
|
*
|
|
145212
145243
|
* @param {string} capabilityId The root capability identifier to dereference.
|
|
145213
|
-
* @returns {
|
|
145244
|
+
* @returns {RootCapability} The root capability object.
|
|
145214
145245
|
* @example a didUpdatePayload with an invoked ZCAP-LD capability containing a patch defining how the DID document
|
|
145215
145246
|
* for did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u SHOULD be mutated.
|
|
145216
145247
|
* ```
|
|
@@ -145236,7 +145267,7 @@ var Appendix = class _Appendix {
|
|
|
145236
145267
|
* "cryptosuite": "schnorr-secp256k1-jcs-2025",
|
|
145237
145268
|
* "verificationMethod": "did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u#initialKey",
|
|
145238
145269
|
* "invocationTarget": "did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u",
|
|
145239
|
-
* "capability": "urn:zcap:root:did%
|
|
145270
|
+
* "capability": "urn:zcap:root:did%3Abtcr2%3Ak1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u",
|
|
145240
145271
|
* "capabilityAction": "Write",
|
|
145241
145272
|
* "proofPurpose": "assertionMethod",
|
|
145242
145273
|
* "proofValue": "z381yXYmxU8NudZ4HXY56DfMN6zfD8syvWcRXzT9xD9uYoQToo8QsXD7ahM3gXTzuay5WJbqTswt2BKaGWYn2hHhVFKJLXaDz"
|
|
@@ -145567,8 +145598,8 @@ var SchnorrMultikey = class _SchnorrMultikey {
|
|
|
145567
145598
|
* @param {string} params.id The id of the multikey (required)
|
|
145568
145599
|
* @param {string} params.controller The controller of the multikey (required)
|
|
145569
145600
|
* @param {Keys} params.keys The Keys of the multikey (optional, required if no publicKey)
|
|
145570
|
-
* @param {
|
|
145571
|
-
* @param {
|
|
145601
|
+
* @param {CompressedSecp256k1PublicKey} params.keys.publicKey The public key of the multikey (optional, required if no privateKey)
|
|
145602
|
+
* @param {Secp256k1SecretKey} params.keys.privateKey The private key of the multikey (optional)
|
|
145572
145603
|
* @throws {MultikeyError} if neither a publicKey nor a privateKey is provided
|
|
145573
145604
|
*/
|
|
145574
145605
|
constructor({ id, controller, keys }) {
|
|
@@ -145587,7 +145618,7 @@ var SchnorrMultikey = class _SchnorrMultikey {
|
|
|
145587
145618
|
const keys = this._keys;
|
|
145588
145619
|
return keys;
|
|
145589
145620
|
}
|
|
145590
|
-
/** @type {
|
|
145621
|
+
/** @type {CompressedSecp256k1PublicKey} @readonly Get the Multikey CompressedSecp256k1PublicKey. */
|
|
145591
145622
|
get publicKey() {
|
|
145592
145623
|
const publicKey2 = this._keys.publicKey;
|
|
145593
145624
|
return publicKey2;
|
|
@@ -145663,7 +145694,7 @@ var SchnorrMultikey = class _SchnorrMultikey {
|
|
|
145663
145694
|
id: this.id,
|
|
145664
145695
|
type: _SchnorrMultikey.type,
|
|
145665
145696
|
controller: this.controller,
|
|
145666
|
-
publicKeyMultibase: this.publicKey.multibase.
|
|
145697
|
+
publicKeyMultibase: this.publicKey.multibase.encoded
|
|
145667
145698
|
};
|
|
145668
145699
|
}
|
|
145669
145700
|
/**
|
|
@@ -145691,10 +145722,10 @@ var SchnorrMultikey = class _SchnorrMultikey {
|
|
|
145691
145722
|
}
|
|
145692
145723
|
const decoded = this.publicKey.decode();
|
|
145693
145724
|
const publicKey2 = decoded.slice(2, decoded.length);
|
|
145694
|
-
const keys = new SchnorrKeyPair({ publicKey: new
|
|
145725
|
+
const keys = new SchnorrKeyPair({ publicKey: new CompressedSecp256k1PublicKey(publicKey2) });
|
|
145695
145726
|
return new _SchnorrMultikey({ id, controller, keys });
|
|
145696
145727
|
}
|
|
145697
|
-
/** @type {boolean} @readonly Get signing ability of the Multikey (i.e. is there a valid
|
|
145728
|
+
/** @type {boolean} @readonly Get signing ability of the Multikey (i.e. is there a valid Secp256k1SecretKey). */
|
|
145698
145729
|
get signer() {
|
|
145699
145730
|
return !!this.keys.secretKey;
|
|
145700
145731
|
}
|
|
@@ -145735,7 +145766,7 @@ var SchnorrMultikey = class _SchnorrMultikey {
|
|
|
145735
145766
|
* @returns {SchnorrMultikey} The new multikey instance
|
|
145736
145767
|
*/
|
|
145737
145768
|
static fromPrivateKey({ id, controller, entropy }) {
|
|
145738
|
-
const secretKey = new
|
|
145769
|
+
const secretKey = new Secp256k1SecretKey(entropy);
|
|
145739
145770
|
const publicKey2 = secretKey.computePublicKey();
|
|
145740
145771
|
const keys = new SchnorrKeyPair({ publicKey: publicKey2, secretKey });
|
|
145741
145772
|
return new _SchnorrMultikey({ id, controller, keys });
|
|
@@ -145749,7 +145780,7 @@ var SchnorrMultikey = class _SchnorrMultikey {
|
|
|
145749
145780
|
* @returns {Multikey} The new multikey instance
|
|
145750
145781
|
*/
|
|
145751
145782
|
static fromPublicKey({ id, controller, publicKeyBytes }) {
|
|
145752
|
-
const keys = new SchnorrKeyPair({ publicKey: new
|
|
145783
|
+
const keys = new SchnorrKeyPair({ publicKey: new CompressedSecp256k1PublicKey(publicKeyBytes) });
|
|
145753
145784
|
return new _SchnorrMultikey({ id, controller, keys });
|
|
145754
145785
|
}
|
|
145755
145786
|
/**
|
|
@@ -145840,9 +145871,9 @@ var KeyManager = class _KeyManager {
|
|
|
145840
145871
|
throw new Error("Method not implemented." + txHex + keyUri);
|
|
145841
145872
|
}
|
|
145842
145873
|
/**
|
|
145843
|
-
* Gets the key pair from the key store and returns a
|
|
145874
|
+
* Gets the key pair from the key store and returns a CompressedSecp256k1PublicKey.
|
|
145844
145875
|
* @param {KeyIdentifier} keyUri The URI of the key to get the public key for.
|
|
145845
|
-
* @returns {Promise<
|
|
145876
|
+
* @returns {Promise<CompressedSecp256k1PublicKey>} The public key associated with the key URI.
|
|
145846
145877
|
*/
|
|
145847
145878
|
async getPublicKey(keyUri) {
|
|
145848
145879
|
const key = await this.getKey(keyUri);
|
|
@@ -145959,11 +145990,11 @@ var KeyManager = class _KeyManager {
|
|
|
145959
145990
|
}
|
|
145960
145991
|
/**
|
|
145961
145992
|
* Computes a multibase-compliant URI from a key.
|
|
145962
|
-
* @param key A SchnorrKeyPair,
|
|
145993
|
+
* @param key A SchnorrKeyPair, CompressedSecp256k1PublicKey, or multibase string
|
|
145963
145994
|
* @returns {string} A multibase URI (e.g. 'urn:mb:zQ3s...')
|
|
145964
145995
|
*/
|
|
145965
145996
|
static toMultibaseUri(data) {
|
|
145966
|
-
const multibase = data instanceof SchnorrKeyPair ? data.publicKey.multibase : data instanceof
|
|
145997
|
+
const multibase = data instanceof SchnorrKeyPair ? data.publicKey.multibase : data instanceof CompressedSecp256k1PublicKey ? data.multibase : data;
|
|
145967
145998
|
return `${MULTIBASE_URI_PREFIX}${multibase}`;
|
|
145968
145999
|
}
|
|
145969
146000
|
/**
|
|
@@ -146106,7 +146137,7 @@ var SingletonBeacon = class _SingletonBeacon extends Beacon {
|
|
|
146106
146137
|
const hashBytes = JSON.canonicalization.encode(import_buffer.Buffer.fromHex(UPDATE_PAYLOAD_HASH), "base58");
|
|
146107
146138
|
const signalsMetadataMap = new Map(Object.entries(signalsMetadata));
|
|
146108
146139
|
if (signalsMetadata) {
|
|
146109
|
-
didUpdatePayload = signalsMetadataMap.get(signal.txid)?.
|
|
146140
|
+
didUpdatePayload = signalsMetadataMap.get(signal.txid)?.didUpdate;
|
|
146110
146141
|
if (!didUpdatePayload) {
|
|
146111
146142
|
throw new SingletonBeaconError("Update Payload not found in signal metadata.", "PROCESS_SIGNAL_ERROR");
|
|
146112
146143
|
}
|
|
@@ -146185,7 +146216,7 @@ var SingletonBeacon = class _SingletonBeacon extends Beacon {
|
|
|
146185
146216
|
if (!spentTx) {
|
|
146186
146217
|
throw new SingletonBeaconError("Failed to send raw transaction.", "SEND_FAILED", { spentTx });
|
|
146187
146218
|
}
|
|
146188
|
-
return { [spentTx]: {
|
|
146219
|
+
return { [spentTx]: { didUpdate: didUpdatePayload } };
|
|
146189
146220
|
}
|
|
146190
146221
|
};
|
|
146191
146222
|
|
|
@@ -146324,7 +146355,14 @@ var BeaconFactory = class {
|
|
|
146324
146355
|
}
|
|
146325
146356
|
};
|
|
146326
146357
|
|
|
146327
|
-
// src/core/crud/
|
|
146358
|
+
// src/core/crud/deactivate.ts
|
|
146359
|
+
init_shim();
|
|
146360
|
+
|
|
146361
|
+
// src/did-btcr2.ts
|
|
146362
|
+
init_shim();
|
|
146363
|
+
var tinysecp4 = __toESM(require_dist2(), 1);
|
|
146364
|
+
|
|
146365
|
+
// src/core/crud/read.ts
|
|
146328
146366
|
init_shim();
|
|
146329
146367
|
|
|
146330
146368
|
// src/utils/beacons.ts
|
|
@@ -146904,7 +146942,7 @@ var bech32m3 = /* @__PURE__ */ genBech32("bech32m");
|
|
|
146904
146942
|
// src/utils/identifier.ts
|
|
146905
146943
|
var Identifier = class {
|
|
146906
146944
|
/**
|
|
146907
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#
|
|
146945
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/#didbtcr2-identifier-encoding | 3.2 did:btcr2 Identifier Encoding}.
|
|
146908
146946
|
*
|
|
146909
146947
|
* A did:btcr2 DID consists of a did:btcr2 prefix, followed by an id-bech32 value, which is a Bech32m encoding of:
|
|
146910
146948
|
* - the specification version;
|
|
@@ -146935,7 +146973,7 @@ var Identifier = class {
|
|
|
146935
146973
|
}
|
|
146936
146974
|
if (idType === "KEY") {
|
|
146937
146975
|
try {
|
|
146938
|
-
new
|
|
146976
|
+
new CompressedSecp256k1PublicKey(genesisBytes);
|
|
146939
146977
|
} catch {
|
|
146940
146978
|
throw new MethodError(
|
|
146941
146979
|
'Expected "genesisBytes" to be a valid compressed secp256k1 public key',
|
|
@@ -146968,7 +147006,7 @@ var Identifier = class {
|
|
|
146968
147006
|
return `did:btcr2:${bech32m3.encodeFromBytes(hrp, dataBytes)}`;
|
|
146969
147007
|
}
|
|
146970
147008
|
/**
|
|
146971
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#
|
|
147009
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/#didbtcr2-identifier-decoding | 3.3 did:btcr2 Identifier Decoding}.
|
|
146972
147010
|
* @param {string} identifier The BTCR2 DID to be parsed
|
|
146973
147011
|
* @returns {DidComponents} The parsed identifier components. See {@link DidComponents} for details.
|
|
146974
147012
|
* @throws {DidError} if an error occurs while parsing the identifier
|
|
@@ -147037,7 +147075,7 @@ var Identifier = class {
|
|
|
147037
147075
|
const genesisBytes = dataBytes.slice(byteIndex + 1);
|
|
147038
147076
|
if (idType === "KEY") {
|
|
147039
147077
|
try {
|
|
147040
|
-
new
|
|
147078
|
+
new CompressedSecp256k1PublicKey(genesisBytes);
|
|
147041
147079
|
} catch {
|
|
147042
147080
|
throw new MethodError(`Invalid genesisBytes: ${genesisBytes}`, INVALID_DID, { identifier });
|
|
147043
147081
|
}
|
|
@@ -147062,7 +147100,7 @@ var Identifier = class {
|
|
|
147062
147100
|
|
|
147063
147101
|
// src/utils/did-document.ts
|
|
147064
147102
|
var BECH32M_CHARS = "";
|
|
147065
|
-
var
|
|
147103
|
+
var DID_REGEX = /did:btcr2:(x1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]*)/g;
|
|
147066
147104
|
var DidVerificationMethod = class {
|
|
147067
147105
|
id;
|
|
147068
147106
|
type;
|
|
@@ -147092,6 +147130,7 @@ var DidDocument2 = class _DidDocument {
|
|
|
147092
147130
|
capabilityDelegation;
|
|
147093
147131
|
service;
|
|
147094
147132
|
constructor(document2) {
|
|
147133
|
+
console.log("Constructing DidDocument with document:", document2);
|
|
147095
147134
|
const idType = document2.id.includes("k1") ? IdentifierTypes.KEY : IdentifierTypes.EXTERNAL;
|
|
147096
147135
|
const isIntermediate = document2.id === ID_PLACEHOLDER_VALUE;
|
|
147097
147136
|
const { id, controller, verificationMethod: vm, service } = document2;
|
|
@@ -147331,6 +147370,7 @@ var DidDocument2 = class _DidDocument {
|
|
|
147331
147370
|
if (!_DidDocument.isValidVerificationRelationships(this)) {
|
|
147332
147371
|
throw new DidDocumentError("Invalid IntermediateDidDocument assertionMethod", INVALID_DID_DOCUMENT, this);
|
|
147333
147372
|
}
|
|
147373
|
+
return true;
|
|
147334
147374
|
}
|
|
147335
147375
|
/**
|
|
147336
147376
|
* Convert the DidDocument to an IntermediateDidDocument.
|
|
@@ -147345,19 +147385,7 @@ var DidDocument2 = class _DidDocument {
|
|
|
147345
147385
|
};
|
|
147346
147386
|
var IntermediateDidDocument = class _IntermediateDidDocument extends DidDocument2 {
|
|
147347
147387
|
constructor(document2) {
|
|
147348
|
-
|
|
147349
|
-
super(intermediateDocument);
|
|
147350
|
-
}
|
|
147351
|
-
/**
|
|
147352
|
-
* Create a minimal IntermediateDidDocument with a placeholder ID.
|
|
147353
|
-
* @param {Array<DidVerificationMethod>} verificationMethod The public key in multibase format.
|
|
147354
|
-
* @param {VerificationRelationships} relationships The public key in multibase format.
|
|
147355
|
-
* @param {Array<BeaconService>} service The service to be included in the document.
|
|
147356
|
-
* @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
|
|
147357
|
-
*/
|
|
147358
|
-
static create(verificationMethod, relationships, service) {
|
|
147359
|
-
const id = ID_PLACEHOLDER_VALUE;
|
|
147360
|
-
return new _IntermediateDidDocument({ id, ...relationships, verificationMethod, service });
|
|
147388
|
+
super(document2);
|
|
147361
147389
|
}
|
|
147362
147390
|
/**
|
|
147363
147391
|
* Convert the IntermediateDidDocument to a DidDocument by replacing the placeholder value with the provided DID.
|
|
@@ -147370,92 +147398,72 @@ var IntermediateDidDocument = class _IntermediateDidDocument extends DidDocument
|
|
|
147370
147398
|
return new DidDocument2(parseThis);
|
|
147371
147399
|
}
|
|
147372
147400
|
/**
|
|
147373
|
-
* Create a DidDocument
|
|
147374
|
-
* @param {
|
|
147375
|
-
* @returns {
|
|
147401
|
+
* Create an IntermediateDidDocument from a DidDocument by replacing the DID with a placeholder value.
|
|
147402
|
+
* @param {DidDocument} didDocument The DidDocument to convert.
|
|
147403
|
+
* @returns {IntermediateDidDocument} The IntermediateDidDocument representation of the DidDocument.
|
|
147376
147404
|
*/
|
|
147377
|
-
static
|
|
147378
|
-
|
|
147405
|
+
static fromDidDocument(didDocument) {
|
|
147406
|
+
const intermediateDocument = JSON.cloneReplace(didDocument, DID_REGEX, ID_PLACEHOLDER_VALUE);
|
|
147407
|
+
return new _IntermediateDidDocument(intermediateDocument);
|
|
147379
147408
|
}
|
|
147380
|
-
};
|
|
147381
|
-
|
|
147382
|
-
// src/core/crud/create.ts
|
|
147383
|
-
var Create = class {
|
|
147384
147409
|
/**
|
|
147385
|
-
*
|
|
147386
|
-
*
|
|
147387
|
-
*
|
|
147388
|
-
* to
|
|
147389
|
-
*
|
|
147390
|
-
* @param {CreateKeyParams} params See {@link CreateKeyParams} for details.
|
|
147391
|
-
* @param {number} params.version did-btcr2 identifier version.
|
|
147392
|
-
* @param {string} params.network did-btcr2 bitcoin network.
|
|
147393
|
-
* @param {KeyBytes} params.pubKeyBytes public key bytes for id creation.
|
|
147394
|
-
* @returns {CreateResponse} A response object of type {@link CreateResponse}.
|
|
147395
|
-
* @throws {DidError} if the public key is missing or invalid.
|
|
147410
|
+
* Create a minimal IntermediateDidDocument with a placeholder ID.
|
|
147411
|
+
* @param {Array<DidVerificationMethod>} verificationMethod The public key in multibase format.
|
|
147412
|
+
* @param {VerificationRelationships} relationships The public key in multibase format.
|
|
147413
|
+
* @param {Array<BeaconService>} service The service to be included in the document.
|
|
147414
|
+
* @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
|
|
147396
147415
|
*/
|
|
147397
|
-
static
|
|
147398
|
-
const
|
|
147399
|
-
|
|
147400
|
-
|
|
147401
|
-
|
|
147402
|
-
|
|
147403
|
-
|
|
147404
|
-
|
|
147416
|
+
static create(verificationMethod, relationships, service) {
|
|
147417
|
+
const id = ID_PLACEHOLDER_VALUE;
|
|
147418
|
+
return new _IntermediateDidDocument({ id, ...relationships, verificationMethod, service });
|
|
147419
|
+
}
|
|
147420
|
+
/**
|
|
147421
|
+
* Create a minimal IntermediateDidDocument from a public key.
|
|
147422
|
+
* @param {KeyBytes} publicKey The public key in bytes format.
|
|
147423
|
+
* @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
|
|
147424
|
+
*/
|
|
147425
|
+
static fromPublicKey(publicKey2, network) {
|
|
147426
|
+
const pk = new CompressedSecp256k1PublicKey(publicKey2);
|
|
147427
|
+
const id = ID_PLACEHOLDER_VALUE;
|
|
147428
|
+
const service = BeaconUtils.generateBeaconService({
|
|
147429
|
+
id: `${id}#key-0`,
|
|
147430
|
+
publicKey: pk.compressed,
|
|
147405
147431
|
network: getNetwork(network),
|
|
147432
|
+
addressType: "p2pkh",
|
|
147406
147433
|
type: "SingletonBeacon"
|
|
147407
147434
|
});
|
|
147408
|
-
const
|
|
147409
|
-
|
|
147410
|
-
|
|
147411
|
-
|
|
147412
|
-
|
|
147435
|
+
const relationships = {
|
|
147436
|
+
authentication: [`${id}#key-0`],
|
|
147437
|
+
assertionMethod: [`${id}#key-0`],
|
|
147438
|
+
capabilityInvocation: [`${id}#key-0`],
|
|
147439
|
+
capabilityDelegation: [`${id}#key-0`]
|
|
147440
|
+
};
|
|
147441
|
+
const verificationMethod = [
|
|
147442
|
+
{
|
|
147443
|
+
id: `${id}#key-0`,
|
|
147413
147444
|
type: "Multikey",
|
|
147414
|
-
controller:
|
|
147415
|
-
publicKeyMultibase:
|
|
147416
|
-
}
|
|
147417
|
-
|
|
147418
|
-
|
|
147419
|
-
return { did: identifier, initialDocument };
|
|
147445
|
+
controller: id,
|
|
147446
|
+
publicKeyMultibase: pk.multibase.encoded
|
|
147447
|
+
}
|
|
147448
|
+
];
|
|
147449
|
+
return _IntermediateDidDocument.create(verificationMethod, relationships, [service]);
|
|
147420
147450
|
}
|
|
147421
147451
|
/**
|
|
147422
|
-
*
|
|
147423
|
-
*
|
|
147424
|
-
*
|
|
147425
|
-
* initial DID documents, including the ability to include Service Endpoints and Beacons that support aggregation.
|
|
147426
|
-
* Inputs include `intermediateDocument`, optional version and network returning initialDidDocument. The
|
|
147427
|
-
* intermediateDocument should be a valid DID document except all places where the DID document requires the use of
|
|
147428
|
-
* the identifier (e.g. the id field). These fields should use placeholder value
|
|
147429
|
-
* `did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`. The intermediateDocument should include at
|
|
147430
|
-
* least one verificationMethod and service of the type SingletonBeacon.
|
|
147431
|
-
*
|
|
147432
|
-
* @param {CreateExternalParams} params See {@link CreateExternalParams} for details.
|
|
147433
|
-
* @param {number} params.version Identifier version.
|
|
147434
|
-
* @param {string} params.network Identifier network name.
|
|
147435
|
-
* @param {string} params.documentBytes Intermediate DID Document bytes.
|
|
147436
|
-
* @returns {CreateResponse} A Promise resolving to {@link CreateResponses}.
|
|
147437
|
-
* @throws {DidError} if the verificationMethod or service objects are missing required properties
|
|
147452
|
+
* Taken an object, convert it to an IntermediateDocuemnt and then to a DidDocument.
|
|
147453
|
+
* @param {JSONObject} object The JSON object to convert.
|
|
147454
|
+
* @returns {DidDocument} The created DidDocument.
|
|
147438
147455
|
*/
|
|
147439
|
-
static
|
|
147440
|
-
|
|
147441
|
-
|
|
147442
|
-
|
|
147443
|
-
|
|
147444
|
-
|
|
147445
|
-
|
|
147446
|
-
return { did, initialDocument };
|
|
147456
|
+
static fromJSON(object2) {
|
|
147457
|
+
return new _IntermediateDidDocument(object2);
|
|
147458
|
+
}
|
|
147459
|
+
};
|
|
147460
|
+
var Document = class {
|
|
147461
|
+
static isValid(didDocument) {
|
|
147462
|
+
return new DidDocument2(didDocument).validateIntermediate();
|
|
147447
147463
|
}
|
|
147448
147464
|
};
|
|
147449
|
-
|
|
147450
|
-
// src/core/crud/deactivate.ts
|
|
147451
|
-
init_shim();
|
|
147452
|
-
|
|
147453
|
-
// src/did-btcr2.ts
|
|
147454
|
-
init_shim();
|
|
147455
|
-
var tinysecp3 = __toESM(require_dist2(), 1);
|
|
147456
147465
|
|
|
147457
147466
|
// src/core/crud/read.ts
|
|
147458
|
-
init_shim();
|
|
147459
147467
|
var bitcoin4 = new BitcoinNetworkConnection();
|
|
147460
147468
|
var Resolve = class {
|
|
147461
147469
|
/**
|
|
@@ -147472,7 +147480,7 @@ var Resolve = class {
|
|
|
147472
147480
|
*/
|
|
147473
147481
|
static deterministic({ identifier, identifierComponents }) {
|
|
147474
147482
|
const { network, genesisBytes } = identifierComponents;
|
|
147475
|
-
const { compressed: publicKey2, multibase: publicKeyMultibase } = new
|
|
147483
|
+
const { compressed: publicKey2, multibase: publicKeyMultibase } = new CompressedSecp256k1PublicKey(genesisBytes);
|
|
147476
147484
|
const service = BeaconUtils.generateBeaconServices({
|
|
147477
147485
|
identifier,
|
|
147478
147486
|
publicKey: publicKey2,
|
|
@@ -147486,7 +147494,7 @@ var Resolve = class {
|
|
|
147486
147494
|
id: `${identifier}#initialKey`,
|
|
147487
147495
|
type: "Multikey",
|
|
147488
147496
|
controller: identifier,
|
|
147489
|
-
publicKeyMultibase: publicKeyMultibase.
|
|
147497
|
+
publicKeyMultibase: publicKeyMultibase.encoded
|
|
147490
147498
|
}],
|
|
147491
147499
|
service
|
|
147492
147500
|
});
|
|
@@ -147622,7 +147630,7 @@ var Resolve = class {
|
|
|
147622
147630
|
targetVersionId,
|
|
147623
147631
|
targetTime,
|
|
147624
147632
|
didDocumentHistory: new Array(),
|
|
147625
|
-
|
|
147633
|
+
updateHashHistory: new Array(),
|
|
147626
147634
|
signalsMetadata,
|
|
147627
147635
|
network
|
|
147628
147636
|
});
|
|
@@ -147654,7 +147662,7 @@ var Resolve = class {
|
|
|
147654
147662
|
* @param {UnixTimestamp} params.targetTime The timestamp used to target specific historical states of a DID document.
|
|
147655
147663
|
* Only Beacon Signals included in the Bitcoin blockchain before the targetTime are processed.
|
|
147656
147664
|
* @param {boolean} params.didDocumentHistory An array of DID documents ordered ascensing by version (1...N).
|
|
147657
|
-
* @param {boolean} params.
|
|
147665
|
+
* @param {boolean} params.updateHashHistory An array of SHA256 hashes of BTCR2 Updates ordered by version that are
|
|
147658
147666
|
* applied to the DID document in order to construct the contemporaryDIDDocument.
|
|
147659
147667
|
* @param {SignalsMetadata} params.signalsMetadata See {@link SignalsMetadata} for details.
|
|
147660
147668
|
* @param {string} params.network The bitcoin network to connect to (mainnet, signet, testnet, regtest).
|
|
@@ -147667,7 +147675,7 @@ var Resolve = class {
|
|
|
147667
147675
|
targetVersionId,
|
|
147668
147676
|
targetTime,
|
|
147669
147677
|
didDocumentHistory,
|
|
147670
|
-
|
|
147678
|
+
updateHashHistory,
|
|
147671
147679
|
signalsMetadata,
|
|
147672
147680
|
network
|
|
147673
147681
|
}) {
|
|
@@ -147690,8 +147698,8 @@ var Resolve = class {
|
|
|
147690
147698
|
for (let update of orderedUpdates) {
|
|
147691
147699
|
const updateTargetVersionId = update.targetVersionId;
|
|
147692
147700
|
if (updateTargetVersionId <= currentVersionId) {
|
|
147693
|
-
|
|
147694
|
-
await this.confirmDuplicateUpdate({ update, updateHashHistory
|
|
147701
|
+
updateHashHistory.push(contemporaryHash);
|
|
147702
|
+
await this.confirmDuplicateUpdate({ update, updateHashHistory });
|
|
147695
147703
|
} else if (updateTargetVersionId === currentVersionId + 1) {
|
|
147696
147704
|
const sourceHash = update.sourceHash.startsWith("z") ? update.sourceHash : `z${update.sourceHash}`;
|
|
147697
147705
|
if (sourceHash !== contemporaryHash) {
|
|
@@ -147707,7 +147715,7 @@ var Resolve = class {
|
|
|
147707
147715
|
const unsecuredUpdate = update;
|
|
147708
147716
|
delete unsecuredUpdate.proof;
|
|
147709
147717
|
const updateHash = await JSON.canonicalization.process(update, "base58");
|
|
147710
|
-
|
|
147718
|
+
updateHashHistory.push(updateHash);
|
|
147711
147719
|
contemporaryHash = await JSON.canonicalization.process(contemporaryDidDocument, "base58");
|
|
147712
147720
|
} else if (update.targetVersionId > currentVersionId + 1) {
|
|
147713
147721
|
throw new ResolveError(
|
|
@@ -147893,12 +147901,12 @@ var Resolve = class {
|
|
|
147893
147901
|
const sidecar = { signalsMetadata };
|
|
147894
147902
|
const service = { id, type, serviceEndpoint: `bitcoin:${address}` };
|
|
147895
147903
|
const beacon = BeaconFactory.establish(service, sidecar);
|
|
147896
|
-
const
|
|
147897
|
-
if (!
|
|
147898
|
-
throw new MethodError("No
|
|
147904
|
+
const didUpdate = await beacon.processSignal(signalTx, signalsMetadata) ?? null;
|
|
147905
|
+
if (!didUpdate) {
|
|
147906
|
+
throw new MethodError("No didUpdate for beacon", "PROCESS_BEACON_SIGNALS_ERROR", { tx, signalsMetadata });
|
|
147899
147907
|
}
|
|
147900
|
-
updates.push(
|
|
147901
|
-
return
|
|
147908
|
+
updates.push(didUpdate);
|
|
147909
|
+
return didUpdate;
|
|
147902
147910
|
}
|
|
147903
147911
|
/**
|
|
147904
147912
|
* Implements {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.2.4 Confirm Duplicate Update}.
|
|
@@ -147913,7 +147921,7 @@ var Resolve = class {
|
|
|
147913
147921
|
* @param {DidUpdatePayload} params.update The DID Update Payload to confirm.
|
|
147914
147922
|
* @param {Array<string>} params.updateHashHistory The history of hashes for previously applied updates.
|
|
147915
147923
|
* @returns {Promise<void>} A promise that resolves if the update is a duplicate, otherwise throws an error.
|
|
147916
|
-
* @throws {
|
|
147924
|
+
* @throws {ResolveError} if the update hash does not match the historical hash.
|
|
147917
147925
|
*/
|
|
147918
147926
|
static async confirmDuplicateUpdate({ update, updateHashHistory }) {
|
|
147919
147927
|
const unsecuredUpdate = update;
|
|
@@ -148061,7 +148069,7 @@ var Update = class {
|
|
|
148061
148069
|
id,
|
|
148062
148070
|
controller,
|
|
148063
148071
|
keys: new SchnorrKeyPair({
|
|
148064
|
-
secretKey:
|
|
148072
|
+
secretKey: Secp256k1SecretKey.decode(secretKeyMultibase)
|
|
148065
148073
|
})
|
|
148066
148074
|
});
|
|
148067
148075
|
if (!multikey) {
|
|
@@ -148130,7 +148138,7 @@ var Update = class {
|
|
|
148130
148138
|
};
|
|
148131
148139
|
|
|
148132
148140
|
// src/did-btcr2.ts
|
|
148133
|
-
initEccLib(
|
|
148141
|
+
initEccLib(tinysecp4);
|
|
148134
148142
|
var DidBtcr2 = class {
|
|
148135
148143
|
/** @type {string} Name of the DID method, as defined in the DID BTCR2 specification */
|
|
148136
148144
|
static methodName = "btcr2";
|
|
@@ -148154,15 +148162,9 @@ var DidBtcr2 = class {
|
|
|
148154
148162
|
*/
|
|
148155
148163
|
static async create(params) {
|
|
148156
148164
|
const { idType, options: options2 = {} } = params;
|
|
148157
|
-
|
|
148158
|
-
|
|
148159
|
-
|
|
148160
|
-
}
|
|
148161
|
-
if (idType === IdentifierTypes.EXTERNAL) {
|
|
148162
|
-
const { intermediateDocument } = params;
|
|
148163
|
-
return await Create.external({ intermediateDocument, options: options2 });
|
|
148164
|
-
}
|
|
148165
|
-
throw new MethodError('Invalid idType: expected "KEY" or "EXTERNAL"', INVALID_DID, params);
|
|
148165
|
+
const { version: version3 = 1, network = "bitcoin" } = options2;
|
|
148166
|
+
const genesisBytes = params.genesisBytes;
|
|
148167
|
+
return Identifier.encode({ idType, genesisBytes, version: version3, network });
|
|
148166
148168
|
}
|
|
148167
148169
|
/**
|
|
148168
148170
|
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.2 Read}.
|
|
@@ -148235,7 +148237,7 @@ var DidBtcr2 = class {
|
|
|
148235
148237
|
* @param {string} params.identifier The btcr2 identifier to be updated.
|
|
148236
148238
|
* @param {DidDocument} params.sourceDocument The DID document being updated.
|
|
148237
148239
|
* @param {string} params.sourceVersionId The versionId of the source document.
|
|
148238
|
-
* @param {
|
|
148240
|
+
* @param {PatchOperation} params.documentPatch The JSON patch to be applied to the source document.
|
|
148239
148241
|
* @param {string} params.verificationMethodId The verificationMethod ID to sign the update
|
|
148240
148242
|
* @param {string[]} params.beaconIds The beacon IDs to announce the update
|
|
148241
148243
|
* @returns {Promise<void>} Promise resolving to void
|
|
@@ -148303,7 +148305,7 @@ var DidBtcr2 = class {
|
|
|
148303
148305
|
};
|
|
148304
148306
|
|
|
148305
148307
|
// src/core/crud/deactivate.ts
|
|
148306
|
-
var
|
|
148308
|
+
var Deactivate = class extends DidBtcr2 {
|
|
148307
148309
|
};
|
|
148308
148310
|
|
|
148309
148311
|
// src/core/key-manager/interface.ts
|
|
@@ -148320,7 +148322,7 @@ init_shim();
|
|
|
148320
148322
|
|
|
148321
148323
|
// src/utils/did-document-builder.ts
|
|
148322
148324
|
init_shim();
|
|
148323
|
-
var
|
|
148325
|
+
var DidDocumentBuilder = class {
|
|
148324
148326
|
document = {};
|
|
148325
148327
|
constructor(initialDocument) {
|
|
148326
148328
|
if (!initialDocument.id) {
|
|
@@ -150886,17 +150888,17 @@ var GeneralUtils = class {
|
|
|
150886
150888
|
export {
|
|
150887
150889
|
Appendix,
|
|
150888
150890
|
BECH32M_CHARS,
|
|
150889
|
-
BTC1_DID_REGEX,
|
|
150890
150891
|
Beacon,
|
|
150891
150892
|
BeaconFactory,
|
|
150892
150893
|
BeaconUtils,
|
|
150893
|
-
Btc1Deactivate,
|
|
150894
|
-
Btc1DidDocumentBuilder,
|
|
150895
150894
|
CIDAggregateBeacon,
|
|
150896
|
-
|
|
150895
|
+
DID_REGEX,
|
|
150896
|
+
Deactivate,
|
|
150897
150897
|
DidBtcr2,
|
|
150898
150898
|
DidDocument2 as DidDocument,
|
|
150899
|
+
DidDocumentBuilder,
|
|
150899
150900
|
DidVerificationMethod,
|
|
150901
|
+
Document,
|
|
150900
150902
|
GeneralUtils,
|
|
150901
150903
|
Identifier,
|
|
150902
150904
|
IntermediateDidDocument,
|