@bsv/sdk 1.3.8 → 1.3.10
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/cjs/package.json +1 -1
- package/dist/cjs/src/auth/Peer.js +1 -1
- package/dist/cjs/src/auth/Peer.js.map +1 -1
- package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js +3 -3
- package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +1 -1
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +12 -0
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/utils/createNonce.js +9 -3
- package/dist/cjs/src/auth/utils/createNonce.js.map +1 -1
- package/dist/cjs/src/auth/utils/getVerifiableCertificates.js.map +1 -1
- package/dist/cjs/src/auth/utils/validateCertificates.js.map +1 -1
- package/dist/cjs/src/auth/utils/verifyNonce.js +3 -2
- package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
- package/dist/cjs/src/script/templates/PushDrop.js +1 -1
- package/dist/cjs/src/script/templates/PushDrop.js.map +1 -1
- package/dist/cjs/src/wallet/ProtoWallet.js +10 -58
- package/dist/cjs/src/wallet/ProtoWallet.js.map +1 -1
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/Peer.js +1 -1
- package/dist/esm/src/auth/Peer.js.map +1 -1
- package/dist/esm/src/auth/certificates/Certificate.js +1 -1
- package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js +3 -3
- package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js +1 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +12 -0
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/utils/createNonce.js +9 -3
- package/dist/esm/src/auth/utils/createNonce.js.map +1 -1
- package/dist/esm/src/auth/utils/getVerifiableCertificates.js.map +1 -1
- package/dist/esm/src/auth/utils/validateCertificates.js.map +1 -1
- package/dist/esm/src/auth/utils/verifyNonce.js +3 -2
- package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
- package/dist/esm/src/script/templates/PushDrop.js +1 -1
- package/dist/esm/src/script/templates/PushDrop.js.map +1 -1
- package/dist/esm/src/wallet/ProtoWallet.js +10 -58
- package/dist/esm/src/wallet/ProtoWallet.js.map +1 -1
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/esm/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/auth/Peer.d.ts +3 -3
- package/dist/types/src/auth/Peer.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/Certificate.d.ts +2 -2
- package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts +7 -7
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts +3 -3
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts +6 -2
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts.map +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts +2 -2
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/auth/utils/createNonce.d.ts +4 -3
- package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -1
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +2 -2
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -1
- package/dist/types/src/auth/utils/validateCertificates.d.ts +2 -2
- package/dist/types/src/auth/utils/validateCertificates.d.ts.map +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts +3 -2
- package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts +2 -2
- package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts.map +1 -1
- package/dist/types/src/script/templates/PushDrop.d.ts +4 -4
- package/dist/types/src/script/templates/PushDrop.d.ts.map +1 -1
- package/dist/types/src/wallet/ProtoWallet.d.ts +12 -24
- package/dist/types/src/wallet/ProtoWallet.d.ts.map +1 -1
- package/dist/types/src/wallet/Wallet.interfaces.d.ts +5 -18
- package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts +4 -4
- package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts +2 -2
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts +3 -3
- package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts +2 -2
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/XDM.d.ts +2 -2
- package/dist/types/src/wallet/substrates/XDM.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/window.CWI.d.ts +2 -2
- package/dist/types/src/wallet/substrates/window.CWI.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/auth.md +80 -40
- package/docs/overlay-tools.md +4 -4
- package/docs/script.md +5 -5
- package/docs/wallet-substrates.md +11 -11
- package/docs/wallet.md +300 -360
- package/package.json +1 -1
- package/src/auth/Peer.ts +4 -4
- package/src/auth/certificates/Certificate.ts +4 -3
- package/src/auth/certificates/MasterCertificate.ts +8 -8
- package/src/auth/certificates/VerifiableCertificate.ts +3 -3
- package/src/auth/certificates/__tests/CompletedProtoWallet.ts +14 -3
- package/src/auth/clients/AuthFetch.ts +3 -3
- package/src/auth/utils/__tests/cryptononce.test.ts +42 -7
- package/src/auth/utils/createNonce.ts +10 -4
- package/src/auth/utils/getVerifiableCertificates.ts +2 -2
- package/src/auth/utils/validateCertificates.ts +2 -2
- package/src/auth/utils/verifyNonce.ts +4 -3
- package/src/overlay-tools/OverlayAdminTokenTemplate.ts +2 -2
- package/src/script/templates/PushDrop.ts +4 -4
- package/src/wallet/ProtoWallet.ts +21 -87
- package/src/wallet/Wallet.interfaces.ts +5 -19
- package/src/wallet/WalletClient.ts +33 -33
- package/src/wallet/__tests/ProtoWallet.test.ts +0 -31
- package/src/wallet/substrates/HTTPWalletJSON.ts +3 -3
- package/src/wallet/substrates/WalletWireProcessor.ts +3 -3
- package/src/wallet/substrates/WalletWireTransceiver.ts +2 -2
- package/src/wallet/substrates/XDM.ts +3 -3
- package/src/wallet/substrates/__tests/WalletWire.integration.test.ts +0 -104
- package/src/wallet/substrates/window.CWI.ts +5 -5
package/package.json
CHANGED
package/src/auth/Peer.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SessionManager } from './SessionManager.js'
|
|
|
2
2
|
import { createNonce, verifyNonce, getVerifiableCertificates, validateCertificates } from './utils/index.js'
|
|
3
3
|
import { AuthMessage, PeerSession, RequestedCertificateSet, Transport } from './types.js'
|
|
4
4
|
import { VerifiableCertificate } from './certificates/VerifiableCertificate.js'
|
|
5
|
-
import { Random, Utils,
|
|
5
|
+
import { Random, Utils, WalletInterface } from '../../mod.js'
|
|
6
6
|
|
|
7
7
|
const AUTH_VERSION = '0.1'
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ const AUTH_VERSION = '0.1'
|
|
|
14
14
|
export class Peer {
|
|
15
15
|
public sessionManager: SessionManager
|
|
16
16
|
private readonly transport: Transport
|
|
17
|
-
private readonly wallet:
|
|
17
|
+
private readonly wallet: WalletInterface
|
|
18
18
|
certificatesToRequest: RequestedCertificateSet
|
|
19
19
|
private readonly onGeneralMessageReceivedCallbacks: Map<number, (senderPublicKey: string, payload: number[]) => void> = new Map()
|
|
20
20
|
private readonly onCertificatesReceivedCallbacks: Map<number, (senderPublicKey: string, certs: VerifiableCertificate[]) => void> = new Map()
|
|
@@ -33,14 +33,14 @@ export class Peer {
|
|
|
33
33
|
/**
|
|
34
34
|
* Creates a new Peer instance
|
|
35
35
|
*
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {WalletInterface} wallet - The wallet instance used for cryptographic operations.
|
|
37
37
|
* @param {Transport} transport - The transport mechanism used for sending and receiving messages.
|
|
38
38
|
* @param {RequestedCertificateSet} [certificatesToRequest] - Optional set of certificates to request from a peer during the initial handshake.
|
|
39
39
|
* @param {SessionManager} [sessionManager] - Optional SessionManager to be used for managing peer sessions.
|
|
40
40
|
* @param {boolean} [autoPersistLastSession] - Whether to auto-persist the session with the last-interacted-with peer. Defaults to true.
|
|
41
41
|
*/
|
|
42
42
|
constructor (
|
|
43
|
-
wallet:
|
|
43
|
+
wallet: WalletInterface,
|
|
44
44
|
transport: Transport,
|
|
45
45
|
certificatesToRequest?: RequestedCertificateSet,
|
|
46
46
|
sessionManager?: SessionManager,
|
|
@@ -5,9 +5,10 @@ import {
|
|
|
5
5
|
HexString,
|
|
6
6
|
OutpointString,
|
|
7
7
|
CertificateFieldNameUnder50Bytes,
|
|
8
|
-
|
|
8
|
+
WalletInterface,
|
|
9
9
|
Signature,
|
|
10
|
-
WalletProtocol
|
|
10
|
+
WalletProtocol,
|
|
11
|
+
ProtoWallet
|
|
11
12
|
} from '../../../mod.js'
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -231,7 +232,7 @@ export default class Certificate {
|
|
|
231
232
|
* @param {Wallet} certifierWallet - The wallet representing the certifier.
|
|
232
233
|
* @returns {Promise<void>}
|
|
233
234
|
*/
|
|
234
|
-
async sign(certifierWallet:
|
|
235
|
+
async sign(certifierWallet: WalletInterface): Promise<void> {
|
|
235
236
|
if (this.signature) {
|
|
236
237
|
throw new Error(`Certificate has already been signed! Signature present: ${this.signature}`)
|
|
237
238
|
}
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
HexString,
|
|
7
7
|
OutpointString,
|
|
8
8
|
PubKeyHex,
|
|
9
|
-
ProtoWallet,
|
|
10
9
|
Random,
|
|
11
|
-
WalletCounterparty
|
|
10
|
+
WalletCounterparty,
|
|
11
|
+
WalletInterface
|
|
12
12
|
} from '../../../mod.js'
|
|
13
13
|
import Certificate from './Certificate.js'
|
|
14
14
|
|
|
@@ -61,12 +61,12 @@ export class MasterCertificate extends Certificate {
|
|
|
61
61
|
* This method uses the `masterKeyring` to decrypt each field's encryption key and then
|
|
62
62
|
* decrypts the field values. The result is a record of plaintext field names and values.
|
|
63
63
|
*
|
|
64
|
-
* @param {
|
|
64
|
+
* @param {WalletInterface} subjectWallet - The wallet of the subject, used to decrypt the master keyring and field values.
|
|
65
65
|
* @returns {Promise<Record<CertificateFieldNameUnder50Bytes, string>>} - A record of field names and their decrypted values in plaintext.
|
|
66
66
|
*
|
|
67
67
|
* @throws {Error} Throws an error if the `masterKeyring` is invalid or if decryption fails for any field.
|
|
68
68
|
*/
|
|
69
|
-
async decryptFields(subjectWallet:
|
|
69
|
+
async decryptFields(subjectWallet: WalletInterface): Promise<Record<CertificateFieldNameUnder50Bytes, string>> {
|
|
70
70
|
// const fields: Record<CertificateFieldNameUnder50Bytes, Base64String> = this.fields
|
|
71
71
|
const decryptedFields: Record<CertificateFieldNameUnder50Bytes, string> = {}
|
|
72
72
|
if (!this.masterKeyring || Object.keys(this.masterKeyring).length === 0) {
|
|
@@ -97,7 +97,7 @@ export class MasterCertificate extends Certificate {
|
|
|
97
97
|
* for the verifier's identity key. The result is a keyring containing the keys necessary
|
|
98
98
|
* for the verifier to access the designated fields.
|
|
99
99
|
*
|
|
100
|
-
* @param {
|
|
100
|
+
* @param {WalletInterface} subjectWallet - The wallet instance of the subject, used to decrypt and re-encrypt field keys.
|
|
101
101
|
* @param {WalletCounterparty} verifier - The verifier who will receive access to the selectively revealed fields. Can be an identity key as hex, 'anyone', or 'self'.
|
|
102
102
|
* @param {string[]} fieldsToReveal - An array of field names to be revealed to the verifier. Must be a subset of the certificate's fields.
|
|
103
103
|
* @param {string} [originator] - Optional originator identifier, used if additional context is needed for decryption and encryption operations.
|
|
@@ -107,7 +107,7 @@ export class MasterCertificate extends Certificate {
|
|
|
107
107
|
* - A field in `fieldsToReveal` does not exist in the certificate.
|
|
108
108
|
* - The decrypted master field key fails to decrypt the corresponding field (indicating an invalid key).
|
|
109
109
|
*/
|
|
110
|
-
async createKeyringForVerifier(subjectWallet:
|
|
110
|
+
async createKeyringForVerifier(subjectWallet: WalletInterface, verifier: WalletCounterparty, fieldsToReveal: string[], originator?: string): Promise<Record<CertificateFieldNameUnder50Bytes, string>> {
|
|
111
111
|
if (!Array.isArray(fieldsToReveal)) {
|
|
112
112
|
throw new Error('fieldsToReveal must be an array of strings')
|
|
113
113
|
}
|
|
@@ -157,7 +157,7 @@ export class MasterCertificate extends Certificate {
|
|
|
157
157
|
* generated symmetric key, which is then encrypted for the subject. The certificate
|
|
158
158
|
* can also includes a revocation outpoint to manage potential revocation.
|
|
159
159
|
*
|
|
160
|
-
* @param {
|
|
160
|
+
* @param {WalletInterface} certifierWallet - The wallet of the certifier, used to sign the certificate and encrypt field keys.
|
|
161
161
|
* @param {WalletCounterparty} subject - The subject for whom the certificate is issued.
|
|
162
162
|
* @param {Record<CertificateFieldNameUnder50Bytes, string>} fields - Unencrypted certificate fields to include, with their names and values.
|
|
163
163
|
* @param {string} certificateType - The type of certificate being issued.
|
|
@@ -169,7 +169,7 @@ export class MasterCertificate extends Certificate {
|
|
|
169
169
|
* @throws {Error} Throws an error if any operation (e.g., encryption, signing) fails during certificate issuance.
|
|
170
170
|
*/
|
|
171
171
|
static async issueCertificateForSubject(
|
|
172
|
-
certifierWallet:
|
|
172
|
+
certifierWallet: WalletInterface,
|
|
173
173
|
subject: WalletCounterparty,
|
|
174
174
|
fields: Record<CertificateFieldNameUnder50Bytes, string>,
|
|
175
175
|
certificateType: string,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
HexString,
|
|
7
7
|
OutpointString,
|
|
8
8
|
PubKeyHex,
|
|
9
|
-
|
|
9
|
+
WalletInterface,
|
|
10
10
|
WalletError
|
|
11
11
|
} from '../../../mod.js'
|
|
12
12
|
import Certificate from './Certificate.js'
|
|
@@ -45,11 +45,11 @@ export class VerifiableCertificate extends Certificate {
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Decrypts selectively revealed certificate fields using the provided keyring and verifier wallet
|
|
48
|
-
* @param {
|
|
48
|
+
* @param {WalletInterface} verifierWallet - The wallet instance of the certificate's verifier, used to decrypt field keys.
|
|
49
49
|
* @returns {Promise<Record<CertificateFieldNameUnder50Bytes, string>>} - A promise that resolves to an object where each key is a field name and each value is the decrypted field value as a string.
|
|
50
50
|
* @throws {Error} Throws an error if any of the decryption operations fail, with a message indicating the failure context.
|
|
51
51
|
*/
|
|
52
|
-
async decryptFields(verifierWallet:
|
|
52
|
+
async decryptFields(verifierWallet: WalletInterface): Promise<Record<CertificateFieldNameUnder50Bytes, string>> {
|
|
53
53
|
if (!this.keyring || Object.keys(this.keyring).length === 0) {
|
|
54
54
|
throw new Error('A keyring is required to decrypt certificate fields for the verifier.')
|
|
55
55
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PrivateKey } from "mod.js"
|
|
2
|
-
import { ProtoWallet,
|
|
2
|
+
import { ProtoWallet, WalletInterface, CreateActionArgs, OriginatorDomainNameStringUnder250Bytes, CreateActionResult, SignActionArgs, SignActionResult, AbortActionArgs, AbortActionResult, ListActionsArgs, ListActionsResult, InternalizeActionArgs, InternalizeActionResult, ListOutputsArgs, ListOutputsResult, RelinquishOutputArgs, RelinquishOutputResult, AcquireCertificateArgs, AcquireCertificateResult, ListCertificatesArgs, ListCertificatesResult, ProveCertificateArgs, ProveCertificateResult, RelinquishCertificateArgs, RelinquishCertificateResult, DiscoverByIdentityKeyArgs, DiscoverCertificatesResult, DiscoverByAttributesArgs, GetHeightResult, GetHeaderArgs, GetHeaderResult, KeyDeriverApi, KeyDeriver, GetPublicKeyArgs, GetPublicKeyResult, PubKeyHex, AuthenticatedResult, GetNetworkResult, GetVersionResult } from "../../../wallet/index.js"
|
|
3
3
|
|
|
4
4
|
// Test Mock wallet which extends ProtoWallet but still implements Wallet interface
|
|
5
5
|
// Unsupported methods throw
|
|
6
|
-
export class CompletedProtoWallet extends ProtoWallet implements
|
|
6
|
+
export class CompletedProtoWallet extends ProtoWallet implements WalletInterface {
|
|
7
7
|
constructor(rootKeyOrKeyDeriver: PrivateKey | 'anyone' | KeyDeriverApi) {
|
|
8
8
|
super(rootKeyOrKeyDeriver)
|
|
9
9
|
if (typeof rootKeyOrKeyDeriver['identityKey'] !== 'string') {
|
|
@@ -11,7 +11,18 @@ export class CompletedProtoWallet extends ProtoWallet implements Wallet {
|
|
|
11
11
|
}
|
|
12
12
|
this.keyDeriver = rootKeyOrKeyDeriver as KeyDeriver
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
isAuthenticated(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<AuthenticatedResult> {
|
|
15
|
+
throw new Error("not implemented")
|
|
16
|
+
}
|
|
17
|
+
waitForAuthentication(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<AuthenticatedResult> {
|
|
18
|
+
throw new Error("not implemented")
|
|
19
|
+
}
|
|
20
|
+
getNetwork(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<GetNetworkResult> {
|
|
21
|
+
throw new Error("not implemented")
|
|
22
|
+
}
|
|
23
|
+
getVersion(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<GetVersionResult> {
|
|
24
|
+
throw new Error("not implemented")
|
|
25
|
+
}
|
|
15
26
|
async getPublicKey(
|
|
16
27
|
args: GetPublicKeyArgs,
|
|
17
28
|
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils, Random, P2PKH, PublicKey,
|
|
1
|
+
import { Utils, Random, P2PKH, PublicKey, WalletInterface } from '../../../mod.js'
|
|
2
2
|
import { Peer } from '../Peer.js'
|
|
3
3
|
import { SimplifiedFetchTransport } from '../transports/SimplifiedFetchTransport.js'
|
|
4
4
|
import { SessionManager } from '../SessionManager.js'
|
|
@@ -26,7 +26,7 @@ const PAYMENT_VERSION = '1.0'
|
|
|
26
26
|
*/
|
|
27
27
|
export class AuthFetch {
|
|
28
28
|
private sessionManager: SessionManager
|
|
29
|
-
private wallet:
|
|
29
|
+
private wallet: WalletInterface
|
|
30
30
|
private callbacks: Record<string, { resolve: Function, reject: Function }> = {}
|
|
31
31
|
private certificatesReceived: VerifiableCertificate[] = []
|
|
32
32
|
private requestedCertificates?: RequestedCertificateSet
|
|
@@ -37,7 +37,7 @@ export class AuthFetch {
|
|
|
37
37
|
* @param wallet - The wallet instance for signing and authentication.
|
|
38
38
|
* @param requestedCertificates - Optional set of certificates to request from peers.
|
|
39
39
|
*/
|
|
40
|
-
constructor(wallet:
|
|
40
|
+
constructor(wallet: WalletInterface, requestedCertificates?: RequestedCertificateSet, sessionManager?: SessionManager) {
|
|
41
41
|
this.wallet = wallet
|
|
42
42
|
this.requestedCertificates = requestedCertificates
|
|
43
43
|
this.sessionManager = sessionManager || new SessionManager()
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { PrivateKey } from '../../../../dist/cjs/src/primitives/index.js'
|
|
2
|
-
import { ProtoWallet } from '../../../../dist/cjs/src/wallet/
|
|
3
|
-
import {
|
|
1
|
+
import { PrivateKey, Random, Utils } from '../../../../dist/cjs/src/primitives/index.js'
|
|
2
|
+
import { ProtoWallet } from '../../../../dist/cjs/src/wallet/ProtoWallet.js'
|
|
3
|
+
import { WalletInterface } from '../../../../dist/cjs/src/wallet/Wallet.interfaces.js'
|
|
4
4
|
import { createNonce } from '../../../../dist/cjs/src/auth/utils/createNonce.js'
|
|
5
5
|
import { verifyNonce } from '../../../../dist/cjs/src/auth/utils/verifyNonce.js'
|
|
6
|
+
import { hash256 } from '../../../../dist/cjs/src/primitives/Hash.js'
|
|
6
7
|
|
|
7
8
|
describe('createNonce', () => {
|
|
8
|
-
let mockWallet:
|
|
9
|
+
let mockWallet: WalletInterface
|
|
9
10
|
|
|
10
11
|
beforeEach(() => {
|
|
11
12
|
mockWallet = {
|
|
12
13
|
createHmac: jest.fn().mockResolvedValue({ hmac: new Uint8Array(16) }),
|
|
13
|
-
} as unknown as
|
|
14
|
+
} as unknown as WalletInterface
|
|
14
15
|
})
|
|
15
16
|
|
|
16
17
|
afterEach(() => {
|
|
@@ -31,13 +32,13 @@ describe('createNonce', () => {
|
|
|
31
32
|
})
|
|
32
33
|
|
|
33
34
|
describe('verifyNonce', () => {
|
|
34
|
-
let mockWallet:
|
|
35
|
+
let mockWallet: WalletInterface
|
|
35
36
|
|
|
36
37
|
beforeEach(() => {
|
|
37
38
|
mockWallet = {
|
|
38
39
|
createHmac: jest.fn().mockResolvedValue({ hmac: new Uint8Array(16) }),
|
|
39
40
|
verifyHmac: jest.fn().mockResolvedValue({ valid: true }),
|
|
40
|
-
} as unknown as
|
|
41
|
+
} as unknown as WalletInterface
|
|
41
42
|
})
|
|
42
43
|
|
|
43
44
|
afterEach(() => {
|
|
@@ -81,4 +82,38 @@ describe('verifyNonce', () => {
|
|
|
81
82
|
|
|
82
83
|
expect(isValid).toEqual(true)
|
|
83
84
|
})
|
|
85
|
+
|
|
86
|
+
it('SerialNumber use-case', async () => {
|
|
87
|
+
const clientWallet = new ProtoWallet(PrivateKey.fromRandom())
|
|
88
|
+
const serverWallet = new ProtoWallet(PrivateKey.fromRandom())
|
|
89
|
+
|
|
90
|
+
// Client creates a random nonce that the server can verify
|
|
91
|
+
const clientNonce = await createNonce(clientWallet, (await serverWallet.getPublicKey({ identityKey: true })).publicKey)
|
|
92
|
+
// The server verifies the client created the nonce provided
|
|
93
|
+
await verifyNonce(clientNonce, serverWallet, (await clientWallet.getPublicKey({ identityKey: true })).publicKey)
|
|
94
|
+
// Server creates a random nonce that the client can verify
|
|
95
|
+
const serverNonce = await createNonce(serverWallet, (await clientWallet.getPublicKey({ identityKey: true })).publicKey)
|
|
96
|
+
// The server compute a serial number from the client and server nonce
|
|
97
|
+
const { hmac: serialNumber } = await serverWallet.createHmac({
|
|
98
|
+
data: clientNonce + serverNonce,
|
|
99
|
+
protocolID: [2, 'certificate creation'],
|
|
100
|
+
keyID: serverNonce + clientNonce,
|
|
101
|
+
counterparty: (await clientWallet.getPublicKey({ identityKey: true })).publicKey
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
// Client verifies server's nonce
|
|
105
|
+
await verifyNonce(serverNonce, clientWallet, (await serverWallet.getPublicKey({ identityKey: true })).publicKey)
|
|
106
|
+
|
|
107
|
+
// Client verifies the server included their nonce
|
|
108
|
+
const { valid } = await clientWallet.verifyHmac({
|
|
109
|
+
hmac: serialNumber,
|
|
110
|
+
data: clientNonce + serverNonce,
|
|
111
|
+
protocolID: [2, 'certificate creation'],
|
|
112
|
+
keyID: serverNonce + clientNonce,
|
|
113
|
+
counterparty: (await serverWallet.getPublicKey({ identityKey: true })).publicKey,
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
console.log(Utils.toBase64(serialNumber))
|
|
117
|
+
expect(valid).toEqual(true)
|
|
118
|
+
})
|
|
84
119
|
})
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { Utils, Random,
|
|
1
|
+
import { Utils, Random, WalletInterface, WalletCounterparty } from '../../../mod.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Creates a nonce derived from a
|
|
4
|
+
* Creates a nonce derived from a wallet
|
|
5
5
|
* @param wallet
|
|
6
|
+
* @param counterparty - The counterparty to the nonce creation. Defaults to 'self'.
|
|
6
7
|
* @returns A random nonce derived with a wallet
|
|
7
8
|
*/
|
|
8
|
-
export async function createNonce(wallet:
|
|
9
|
+
export async function createNonce(wallet: WalletInterface, counterparty: WalletCounterparty = 'self'): Promise<string> {
|
|
9
10
|
// Generate 16 random bytes for the first half of the data
|
|
10
11
|
const firstHalf = Random(16)
|
|
11
12
|
// Create an sha256 HMAC
|
|
12
|
-
const { hmac } = await wallet.createHmac({
|
|
13
|
+
const { hmac } = await wallet.createHmac({
|
|
14
|
+
protocolID: [2, 'server hmac'],
|
|
15
|
+
keyID: Utils.toUTF8(firstHalf),
|
|
16
|
+
data: firstHalf,
|
|
17
|
+
counterparty
|
|
18
|
+
})
|
|
13
19
|
// Concatenate firstHalf and secondHalf as the nonce bytes
|
|
14
20
|
const nonceBytes = [...firstHalf, ...hmac]
|
|
15
21
|
return Utils.toBase64(nonceBytes)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VerifiableCertificate } from "../certificates/VerifiableCertificate.js"
|
|
2
|
-
import {
|
|
2
|
+
import { WalletInterface } from "../../../mod.js"
|
|
3
3
|
import { RequestedCertificateSet } from "../types.js"
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ import { RequestedCertificateSet } from "../types.js"
|
|
|
10
10
|
* @param {string} verifierIdentityKey - The public key of the verifier requesting the certificates.
|
|
11
11
|
* @returns {Promise<VerifiableCertificate[]>} An array of verifiable certificates.
|
|
12
12
|
*/
|
|
13
|
-
export const getVerifiableCertificates = async (wallet:
|
|
13
|
+
export const getVerifiableCertificates = async (wallet: WalletInterface, requestedCertificates: RequestedCertificateSet, verifierIdentityKey: string): Promise<VerifiableCertificate[]> => {
|
|
14
14
|
// Find matching certificates we have
|
|
15
15
|
// Note: This may return multiple certificates that match the correct type.
|
|
16
16
|
const matchingCertificates = await wallet.listCertificates({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WalletInterface } from "../../wallet/index.js"
|
|
2
2
|
import { AuthMessage, RequestedCertificateSet } from "../types.js"
|
|
3
3
|
import { VerifiableCertificate } from "../certificates/VerifiableCertificate.js"
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import { VerifiableCertificate } from "../certificates/VerifiableCertificate.js"
|
|
|
10
10
|
* @returns {Promise<void>}
|
|
11
11
|
* @throws Will throw an error if certificate validation or field decryption fails.
|
|
12
12
|
*/
|
|
13
|
-
export const validateCertificates = async (verifierWallet:
|
|
13
|
+
export const validateCertificates = async (verifierWallet: WalletInterface, message: AuthMessage, certificatesRequested?: RequestedCertificateSet): Promise<void> => {
|
|
14
14
|
await Promise.all(message.certificates.map(async (incomingCert: VerifiableCertificate) => {
|
|
15
15
|
if (incomingCert.subject !== message.identityKey) {
|
|
16
16
|
throw new Error(`The subject of one of your certificates ("${incomingCert.subject}") is not the same as the request sender ("${message.identityKey}").`)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Utils,
|
|
1
|
+
import { Utils, WalletCounterparty, WalletInterface } from '../../../mod.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Verifies a nonce derived from a wallet
|
|
5
5
|
* @param nonce - A nonce to verify as a base64 string.
|
|
6
6
|
* @param wallet
|
|
7
|
+
* @param counterparty - The counterparty to the nonce creation. Defaults to 'self'.
|
|
7
8
|
* @returns The status of the validation
|
|
8
9
|
*/
|
|
9
|
-
export async function verifyNonce(nonce: string, wallet:
|
|
10
|
+
export async function verifyNonce(nonce: string, wallet: WalletInterface, counterparty: WalletCounterparty = 'self'): Promise<boolean> {
|
|
10
11
|
// Convert nonce from base64 string to Uint8Array
|
|
11
12
|
const buffer = Utils.toArray(nonce, 'base64')
|
|
12
13
|
|
|
@@ -20,7 +21,7 @@ export async function verifyNonce(nonce: string, wallet: Wallet): Promise<boolea
|
|
|
20
21
|
hmac,
|
|
21
22
|
protocolID: [2, 'server hmac'],
|
|
22
23
|
keyID: Utils.toUTF8(data),
|
|
23
|
-
counterparty
|
|
24
|
+
counterparty
|
|
24
25
|
})
|
|
25
26
|
|
|
26
27
|
return valid
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PushDrop from '../script/templates/PushDrop.js'
|
|
2
|
-
import {
|
|
2
|
+
import { WalletInterface } from '../wallet/Wallet.interfaces.js'
|
|
3
3
|
import { LockingScript, ScriptTemplate, UnlockingScript } from '../script/index.js'
|
|
4
4
|
import { Transaction } from '../transaction/index.js'
|
|
5
5
|
import { Utils } from '../primitives/index.js'
|
|
@@ -39,7 +39,7 @@ export default class OverlayAdminTokenTemplate implements ScriptTemplate {
|
|
|
39
39
|
* Constructs a new Overlay Admin template instance
|
|
40
40
|
* @param wallet Wallet to use for locking and unlocking
|
|
41
41
|
*/
|
|
42
|
-
constructor (wallet:
|
|
42
|
+
constructor (wallet: WalletInterface) {
|
|
43
43
|
this.pushDrop = new PushDrop(wallet)
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ScriptTemplate, LockingScript, UnlockingScript, OP } from '../index.js'
|
|
2
2
|
import { Utils, Hash, TransactionSignature, Signature, PublicKey } from '../../primitives/index.js'
|
|
3
|
-
import {
|
|
3
|
+
import { WalletInterface } from '../../wallet/Wallet.interfaces.js'
|
|
4
4
|
import { Transaction } from '../../transaction/index.js'
|
|
5
5
|
import { SecurityLevel } from '../../wallet/Wallet.interfaces.js'
|
|
6
6
|
|
|
@@ -44,7 +44,7 @@ const createMinimallyEncodedScriptChunk = (data: number[]): { op: number, data?:
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export default class PushDrop implements ScriptTemplate {
|
|
47
|
-
wallet:
|
|
47
|
+
wallet: WalletInterface
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Decodes a PushDrop script back into its token fields and the locking public key. If a signature was present, it will be the last field returned.
|
|
@@ -84,9 +84,9 @@ export default class PushDrop implements ScriptTemplate {
|
|
|
84
84
|
/**
|
|
85
85
|
* Constructs a new instance of the PushDrop class.
|
|
86
86
|
*
|
|
87
|
-
* @param {
|
|
87
|
+
* @param {WalletInterface} wallet - The wallet interface used for creating signatures and accessing public keys.
|
|
88
88
|
*/
|
|
89
|
-
constructor(wallet:
|
|
89
|
+
constructor(wallet: WalletInterface) {
|
|
90
90
|
this.wallet = wallet
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
GetPublicKeyArgs,
|
|
11
11
|
GetVersionResult,
|
|
12
12
|
OriginatorDomainNameStringUnder250Bytes,
|
|
13
|
-
ProtoWalletApi,
|
|
14
13
|
PubKeyHex,
|
|
15
14
|
RevealCounterpartyKeyLinkageArgs,
|
|
16
15
|
RevealCounterpartyKeyLinkageResult,
|
|
@@ -26,59 +25,26 @@ import {
|
|
|
26
25
|
WalletEncryptResult
|
|
27
26
|
} from './Wallet.interfaces.js'
|
|
28
27
|
|
|
29
|
-
const privilegedError = new Error('ProtoWallet is a single-keyring wallet, operating without context about whether its configured keyring is privileged.')
|
|
30
|
-
|
|
31
28
|
/**
|
|
32
29
|
* A ProtoWallet is precursor to a full wallet, capable of performing all foundational cryptographic operations.
|
|
33
30
|
* It can derive keys, create signatures, facilitate encryption and HMAC operations, and reveal key linkages.
|
|
34
31
|
*
|
|
35
32
|
* However, ProtoWallet does not create transactions, manage outputs, interact with the blockchain,
|
|
36
|
-
* enable the management of identity certificates, or store any data.
|
|
33
|
+
* enable the management of identity certificates, or store any data. It is also not concerned with privileged keys.
|
|
37
34
|
*/
|
|
38
|
-
export class ProtoWallet
|
|
35
|
+
export class ProtoWallet {
|
|
39
36
|
keyDeriver: KeyDeriverApi
|
|
40
37
|
|
|
41
|
-
constructor(rootKeyOrKeyDeriver: PrivateKey | 'anyone' | KeyDeriverApi) {
|
|
38
|
+
constructor (rootKeyOrKeyDeriver: PrivateKey | 'anyone' | KeyDeriverApi) {
|
|
42
39
|
if (typeof (rootKeyOrKeyDeriver as KeyDeriver).identityKey !== 'string') {
|
|
43
40
|
rootKeyOrKeyDeriver = new KeyDeriver(rootKeyOrKeyDeriver as PrivateKey | 'anyone')
|
|
44
41
|
}
|
|
45
42
|
this.keyDeriver = rootKeyOrKeyDeriver as KeyDeriver
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
async
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async waitForAuthentication(args: {}, Originator?: OriginatorDomainNameStringUnder250Bytes): Promise<AuthenticatedResult> {
|
|
53
|
-
return { authenticated: true }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async getNetwork(args: {}, Originator?: OriginatorDomainNameStringUnder250Bytes): Promise<GetNetworkResult> {
|
|
57
|
-
return { network: 'mainnet' }
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async getVersion(args: {}, Originator?: OriginatorDomainNameStringUnder250Bytes): Promise<GetVersionResult> {
|
|
61
|
-
return { version: 'proto-1.0.0' }
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Convenience method to obtain the identityKey.
|
|
66
|
-
* @param originator
|
|
67
|
-
* @returns `await this.getPublicKey({ identityKey: true }, originator)`
|
|
68
|
-
*/
|
|
69
|
-
async getIdentityKey(
|
|
70
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
45
|
+
async getPublicKey (
|
|
46
|
+
args: GetPublicKeyArgs
|
|
71
47
|
): Promise<{ publicKey: PubKeyHex }> {
|
|
72
|
-
return await this.getPublicKey({ identityKey: true }, originator)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async getPublicKey(
|
|
76
|
-
args: GetPublicKeyArgs,
|
|
77
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
78
|
-
): Promise<{ publicKey: PubKeyHex }> {
|
|
79
|
-
if (args.privileged) {
|
|
80
|
-
throw privilegedError
|
|
81
|
-
}
|
|
82
48
|
if (args.identityKey) {
|
|
83
49
|
return { publicKey: this.keyDeriver.rootKey.toPublicKey().toString() }
|
|
84
50
|
} else {
|
|
@@ -98,13 +64,9 @@ export class ProtoWallet implements ProtoWalletApi {
|
|
|
98
64
|
}
|
|
99
65
|
}
|
|
100
66
|
|
|
101
|
-
async revealCounterpartyKeyLinkage(
|
|
102
|
-
args: RevealCounterpartyKeyLinkageArgs
|
|
103
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
67
|
+
async revealCounterpartyKeyLinkage (
|
|
68
|
+
args: RevealCounterpartyKeyLinkageArgs
|
|
104
69
|
): Promise<RevealCounterpartyKeyLinkageResult> {
|
|
105
|
-
if (args.privileged) {
|
|
106
|
-
throw privilegedError
|
|
107
|
-
}
|
|
108
70
|
const { publicKey: identityKey } = await this.getPublicKey({ identityKey: true })
|
|
109
71
|
const linkage = this.keyDeriver.revealCounterpartySecret(args.counterparty)
|
|
110
72
|
const linkageProof = new Schnorr().generateProof(this.keyDeriver.rootKey, this.keyDeriver.rootKey.toPublicKey(), PublicKey.fromString(args.counterparty), Point.fromDER(linkage))
|
|
@@ -136,13 +98,9 @@ export class ProtoWallet implements ProtoWalletApi {
|
|
|
136
98
|
}
|
|
137
99
|
}
|
|
138
100
|
|
|
139
|
-
async revealSpecificKeyLinkage(
|
|
140
|
-
args: RevealSpecificKeyLinkageArgs
|
|
141
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
101
|
+
async revealSpecificKeyLinkage (
|
|
102
|
+
args: RevealSpecificKeyLinkageArgs
|
|
142
103
|
): Promise<RevealSpecificKeyLinkageResult> {
|
|
143
|
-
if (args.privileged) {
|
|
144
|
-
throw privilegedError
|
|
145
|
-
}
|
|
146
104
|
const { publicKey: identityKey } = await this.getPublicKey({ identityKey: true })
|
|
147
105
|
const linkage = this.keyDeriver.revealSpecificSecret(
|
|
148
106
|
args.counterparty,
|
|
@@ -173,13 +131,9 @@ export class ProtoWallet implements ProtoWalletApi {
|
|
|
173
131
|
}
|
|
174
132
|
}
|
|
175
133
|
|
|
176
|
-
async encrypt(
|
|
177
|
-
args: WalletEncryptArgs
|
|
178
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
134
|
+
async encrypt (
|
|
135
|
+
args: WalletEncryptArgs
|
|
179
136
|
): Promise<WalletEncryptResult> {
|
|
180
|
-
if (args.privileged) {
|
|
181
|
-
throw privilegedError
|
|
182
|
-
}
|
|
183
137
|
const key = this.keyDeriver.deriveSymmetricKey(
|
|
184
138
|
args.protocolID,
|
|
185
139
|
args.keyID,
|
|
@@ -188,13 +142,9 @@ export class ProtoWallet implements ProtoWalletApi {
|
|
|
188
142
|
return { ciphertext: key.encrypt(args.plaintext) as number[] }
|
|
189
143
|
}
|
|
190
144
|
|
|
191
|
-
async decrypt(
|
|
192
|
-
args: WalletDecryptArgs
|
|
193
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
145
|
+
async decrypt (
|
|
146
|
+
args: WalletDecryptArgs
|
|
194
147
|
): Promise<WalletDecryptResult> {
|
|
195
|
-
if (args.privileged) {
|
|
196
|
-
throw privilegedError
|
|
197
|
-
}
|
|
198
148
|
const key = this.keyDeriver.deriveSymmetricKey(
|
|
199
149
|
args.protocolID,
|
|
200
150
|
args.keyID,
|
|
@@ -203,13 +153,9 @@ export class ProtoWallet implements ProtoWalletApi {
|
|
|
203
153
|
return { plaintext: key.decrypt(args.ciphertext) as number[] }
|
|
204
154
|
}
|
|
205
155
|
|
|
206
|
-
async createHmac(
|
|
207
|
-
args: CreateHmacArgs
|
|
208
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
156
|
+
async createHmac (
|
|
157
|
+
args: CreateHmacArgs
|
|
209
158
|
): Promise<CreateHmacResult> {
|
|
210
|
-
if (args.privileged) {
|
|
211
|
-
throw privilegedError
|
|
212
|
-
}
|
|
213
159
|
const key = this.keyDeriver.deriveSymmetricKey(
|
|
214
160
|
args.protocolID,
|
|
215
161
|
args.keyID,
|
|
@@ -218,13 +164,9 @@ export class ProtoWallet implements ProtoWalletApi {
|
|
|
218
164
|
return { hmac: Hash.sha256hmac(key.toArray(), args.data) }
|
|
219
165
|
}
|
|
220
166
|
|
|
221
|
-
async verifyHmac(
|
|
222
|
-
args: VerifyHmacArgs
|
|
223
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
167
|
+
async verifyHmac (
|
|
168
|
+
args: VerifyHmacArgs
|
|
224
169
|
): Promise<VerifyHmacResult> {
|
|
225
|
-
if (args.privileged) {
|
|
226
|
-
throw privilegedError
|
|
227
|
-
}
|
|
228
170
|
const key = this.keyDeriver.deriveSymmetricKey(
|
|
229
171
|
args.protocolID,
|
|
230
172
|
args.keyID,
|
|
@@ -239,13 +181,9 @@ export class ProtoWallet implements ProtoWalletApi {
|
|
|
239
181
|
return { valid }
|
|
240
182
|
}
|
|
241
183
|
|
|
242
|
-
async createSignature(
|
|
243
|
-
args: CreateSignatureArgs
|
|
244
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
184
|
+
async createSignature (
|
|
185
|
+
args: CreateSignatureArgs
|
|
245
186
|
): Promise<CreateSignatureResult> {
|
|
246
|
-
if (args.privileged) {
|
|
247
|
-
throw privilegedError
|
|
248
|
-
}
|
|
249
187
|
if (!args.hashToDirectlySign && !args.data) {
|
|
250
188
|
throw new Error('args.data or args.hashToDirectlySign must be valid')
|
|
251
189
|
}
|
|
@@ -258,13 +196,9 @@ export class ProtoWallet implements ProtoWalletApi {
|
|
|
258
196
|
return { signature: ECDSA.sign(new BigNumber(hash), key, true).toDER() as number[] }
|
|
259
197
|
}
|
|
260
198
|
|
|
261
|
-
async verifySignature(
|
|
262
|
-
args: VerifySignatureArgs
|
|
263
|
-
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
199
|
+
async verifySignature (
|
|
200
|
+
args: VerifySignatureArgs
|
|
264
201
|
): Promise<VerifySignatureResult> {
|
|
265
|
-
if (args.privileged) {
|
|
266
|
-
throw privilegedError
|
|
267
|
-
}
|
|
268
202
|
if (!args.hashToDirectlyVerify && !args.data) {
|
|
269
203
|
throw new Error('args.data or args.hashToDirectlyVerify must be valid')
|
|
270
204
|
}
|