xpi-ts 0.2.22 → 0.2.24
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/lib/bitcore/crypto/point.js +2 -2
- package/dist/cjs/lib/bitcore/index.js +162 -162
- package/dist/esm/lib/bitcore/crypto/point.js +2 -2
- package/dist/esm/lib/bitcore/index.js +42 -42
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/address.d.ts +116 -0
- package/dist/types/lib/bitcore/address.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/block.d.ts +214 -0
- package/dist/types/lib/bitcore/block/block.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/blockheader.d.ts +220 -0
- package/dist/types/lib/bitcore/block/blockheader.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/merkleblock.d.ts +206 -0
- package/dist/types/lib/bitcore/block/merkleblock.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/bn.d.ts +224 -0
- package/dist/types/lib/bitcore/crypto/bn.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/ecdsa.d.ts +122 -0
- package/dist/types/lib/bitcore/crypto/ecdsa.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/hash.d.ts +56 -0
- package/dist/types/lib/bitcore/crypto/hash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/index.d.ts +4 -0
- package/dist/types/lib/bitcore/crypto/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/musig2.d.ts +282 -0
- package/dist/types/lib/bitcore/crypto/musig2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/point.d.ts +87 -0
- package/dist/types/lib/bitcore/crypto/point.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/random.d.ts +48 -0
- package/dist/types/lib/bitcore/crypto/random.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/schnorr.d.ts +203 -0
- package/dist/types/lib/bitcore/crypto/schnorr.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/signature.d.ts +452 -0
- package/dist/types/lib/bitcore/crypto/signature.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/sigtype.d.ts +46 -0
- package/dist/types/lib/bitcore/crypto/sigtype.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/base58.d.ts +68 -0
- package/dist/types/lib/bitcore/encoding/base58.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/base58check.d.ts +58 -0
- package/dist/types/lib/bitcore/encoding/base58check.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/bufferreader.d.ts +112 -0
- package/dist/types/lib/bitcore/encoding/bufferreader.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/bufferwriter.d.ts +144 -0
- package/dist/types/lib/bitcore/encoding/bufferwriter.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/varint.d.ts +86 -0
- package/dist/types/lib/bitcore/encoding/varint.d.ts.map +1 -1
- package/dist/types/lib/bitcore/errors.d.ts +4 -0
- package/dist/types/lib/bitcore/errors.d.ts.map +1 -1
- package/dist/types/lib/bitcore/hdprivatekey.d.ts +59 -0
- package/dist/types/lib/bitcore/hdprivatekey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/hdpublickey.d.ts +145 -0
- package/dist/types/lib/bitcore/hdpublickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/index.d.ts +58 -54
- package/dist/types/lib/bitcore/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/message.d.ts +63 -0
- package/dist/types/lib/bitcore/message.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/errors.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/errors.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/index.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/mnemonic.d.ts +106 -0
- package/dist/types/lib/bitcore/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/pbkdf2.d.ts +13 -0
- package/dist/types/lib/bitcore/mnemonic/pbkdf2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/english.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/words/english.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/french.d.ts +5 -0
- package/dist/types/lib/bitcore/mnemonic/words/french.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/index.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/words/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/index.d.ts +14 -0
- package/dist/types/lib/bitcore/musig2/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/session.d.ts +254 -0
- package/dist/types/lib/bitcore/musig2/session.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/signer.d.ts +212 -0
- package/dist/types/lib/bitcore/musig2/signer.d.ts.map +1 -1
- package/dist/types/lib/bitcore/networks.d.ts +17 -0
- package/dist/types/lib/bitcore/networks.d.ts.map +1 -1
- package/dist/types/lib/bitcore/opcode.d.ts +151 -0
- package/dist/types/lib/bitcore/opcode.d.ts.map +1 -1
- package/dist/types/lib/bitcore/privatekey.d.ts +80 -0
- package/dist/types/lib/bitcore/privatekey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/publickey.d.ts +195 -0
- package/dist/types/lib/bitcore/publickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/chunk.d.ts +51 -0
- package/dist/types/lib/bitcore/script/chunk.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/condition-stack.d.ts +60 -0
- package/dist/types/lib/bitcore/script/interpreter/condition-stack.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/index.d.ts +23 -0
- package/dist/types/lib/bitcore/script/interpreter/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/interpreter.d.ts +86 -0
- package/dist/types/lib/bitcore/script/interpreter/interpreter.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/script-num.d.ts +115 -0
- package/dist/types/lib/bitcore/script/interpreter/script-num.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/types.d.ts +119 -0
- package/dist/types/lib/bitcore/script/interpreter/types.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/taproot.d.ts +297 -0
- package/dist/types/lib/bitcore/script/taproot.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script.d.ts +510 -0
- package/dist/types/lib/bitcore/script.d.ts.map +1 -1
- package/dist/types/lib/bitcore/taproot/musig2.d.ts +153 -0
- package/dist/types/lib/bitcore/taproot/musig2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/multisig.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/multisig.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/multisigscripthash.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/multisigscripthash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/publickey.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/publickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/publickeyhash.d.ts +14 -0
- package/dist/types/lib/bitcore/transaction/input/publickeyhash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/taproot.d.ts +22 -0
- package/dist/types/lib/bitcore/transaction/input/taproot.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input.d.ts +418 -0
- package/dist/types/lib/bitcore/transaction/input.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/outpoint.d.ts +110 -0
- package/dist/types/lib/bitcore/transaction/outpoint.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/output.d.ts +83 -0
- package/dist/types/lib/bitcore/transaction/output.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/sighash.d.ts +69 -0
- package/dist/types/lib/bitcore/transaction/sighash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/signature.d.ts +98 -0
- package/dist/types/lib/bitcore/transaction/signature.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/transaction.d.ts +379 -0
- package/dist/types/lib/bitcore/transaction/transaction.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/unspentoutput.d.ts +61 -0
- package/dist/types/lib/bitcore/transaction/unspentoutput.d.ts.map +1 -1
- package/dist/types/lib/bitcore/unit.d.ts +140 -0
- package/dist/types/lib/bitcore/unit.d.ts.map +1 -1
- package/dist/types/lib/bitcore/uri.d.ts +34 -0
- package/dist/types/lib/bitcore/uri.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/base32.d.ts +55 -0
- package/dist/types/lib/bitcore/util/base32.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/bits.d.ts +76 -0
- package/dist/types/lib/bitcore/util/bits.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/buffer.d.ts +135 -0
- package/dist/types/lib/bitcore/util/buffer.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/convertBits.d.ts +15 -0
- package/dist/types/lib/bitcore/util/convertBits.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/js.d.ts +19 -0
- package/dist/types/lib/bitcore/util/js.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/merkle.d.ts +85 -0
- package/dist/types/lib/bitcore/util/merkle.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/preconditions.d.ts +29 -0
- package/dist/types/lib/bitcore/util/preconditions.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util.d.ts +7 -0
- package/dist/types/lib/bitcore/util.d.ts.map +1 -1
- package/dist/types/lib/bitcore/xaddress.d.ts +117 -0
- package/dist/types/lib/bitcore/xaddress.d.ts.map +1 -1
- package/dist/types/lib/lokad.d.ts +292 -0
- package/dist/types/lib/lokad.d.ts.map +1 -1
- package/dist/types/lib/nft.d.ts +434 -0
- package/dist/types/lib/nft.d.ts.map +1 -1
- package/dist/types/lib/rank/api.d.ts +13 -0
- package/dist/types/lib/rank/api.d.ts.map +1 -1
- package/dist/types/lib/rank/index.d.ts +153 -0
- package/dist/types/lib/rank/index.d.ts.map +1 -1
- package/dist/types/lib/rank/opcode.d.ts +6 -2
- package/dist/types/lib/rank/opcode.d.ts.map +1 -1
- package/dist/types/lib/rank/script.d.ts +10 -0
- package/dist/types/lib/rank/script.d.ts.map +1 -1
- package/dist/types/lib/rank/transaction.d.ts +11 -0
- package/dist/types/lib/rank/transaction.d.ts.map +1 -1
- package/dist/types/lib/rpc.d.ts +176 -0
- package/dist/types/lib/rpc.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts +27 -0
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/dist/types/utils/env.d.ts +15 -0
- package/dist/types/utils/env.d.ts.map +1 -1
- package/dist/types/utils/string.d.ts +57 -0
- package/dist/types/utils/string.d.ts.map +1 -1
- package/dist/types/utils/wallet.d.ts +43 -1
- package/dist/types/utils/wallet.d.ts.map +1 -1
- package/package.json +1 -1
- package/tsconfig.types.json +2 -1
|
@@ -1,40 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schnorr signature implementation for Lotus
|
|
3
|
+
*
|
|
4
|
+
* This implements the custom Schnorr signature scheme used by Lotus (BCH-derived),
|
|
5
|
+
* which is different from BIP340 (Bitcoin Taproot).
|
|
6
|
+
*
|
|
7
|
+
* Reference: lotusd/src/secp256k1/src/modules/schnorr/schnorr_impl.h
|
|
8
|
+
*
|
|
9
|
+
* Key Differences from BIP340:
|
|
10
|
+
* - Uses compressed public key (33 bytes) instead of x-only (32 bytes)
|
|
11
|
+
* - Hash construction: e = Hash(R.x || compressed(P) || m) instead of Hash(R.x || P.x || m)
|
|
12
|
+
* - Verification equation: R = s*G - e*P (standard Schnorr)
|
|
13
|
+
* - Checks that R.y is a quadratic residue (Jacobi symbol = 1)
|
|
14
|
+
*
|
|
15
|
+
* Signature Format:
|
|
16
|
+
* - 64 bytes total: [R.x (32 bytes) || s (32 bytes)]
|
|
17
|
+
* - No sighash byte appended to raw signature
|
|
18
|
+
*
|
|
19
|
+
* Signing: s = k + e*x where e = Hash(R.x || compressed(P) || m) mod n
|
|
20
|
+
* Verification: Check that s*G - e*P has x-coordinate equal to r and y is quadratic residue
|
|
21
|
+
*/
|
|
1
22
|
import { BN } from './bn';
|
|
2
23
|
import { Signature } from './signature';
|
|
3
24
|
import { PrivateKey } from '../privatekey';
|
|
4
25
|
import { PublicKey } from '../publickey';
|
|
5
26
|
import type { Buffer } from 'buffer/';
|
|
27
|
+
/**
|
|
28
|
+
* Data structure for initializing a Schnorr signature instance
|
|
29
|
+
*/
|
|
6
30
|
export interface SchnorrData {
|
|
31
|
+
/** 32-byte hash buffer to sign or verify */
|
|
7
32
|
hashbuf?: Buffer;
|
|
33
|
+
/** Byte endianness for hash interpretation */
|
|
8
34
|
endian?: 'little' | 'big';
|
|
35
|
+
/** Private key for signing operations */
|
|
9
36
|
privkey?: PrivateKey;
|
|
37
|
+
/** Public key for verification */
|
|
10
38
|
pubkey?: PublicKey;
|
|
39
|
+
/** Schnorr signature object */
|
|
11
40
|
sig?: Signature;
|
|
41
|
+
/** Result of signature verification */
|
|
12
42
|
verified?: boolean;
|
|
13
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Schnorr signature implementation for Lotus (BCH-derived)
|
|
46
|
+
*
|
|
47
|
+
* This class implements the custom Schnorr signature scheme used by Lotus,
|
|
48
|
+
* which is different from BIP340 (Bitcoin Taproot).
|
|
49
|
+
*
|
|
50
|
+
* Key Features:
|
|
51
|
+
* - Uses compressed public key (33 bytes) instead of x-only (32 bytes)
|
|
52
|
+
* - Hash construction: e = Hash(R.x || compressed(P) || m)
|
|
53
|
+
* - Verification equation: R = s*G - e*P
|
|
54
|
+
* - Checks that R.y is a quadratic residue (Jacobi symbol = 1)
|
|
55
|
+
*
|
|
56
|
+
* Signature Format:
|
|
57
|
+
* - 64 bytes total: [R.x (32 bytes) || s (32 bytes)]
|
|
58
|
+
* - No sighash byte appended to raw signature
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Sign a message hash
|
|
63
|
+
* const schnorr = new Schnorr({ privkey, hashbuf })
|
|
64
|
+
* schnorr.sign()
|
|
65
|
+
*
|
|
66
|
+
* // Verify a signature
|
|
67
|
+
* const isValid = Schnorr.verify(hashbuf, sig, pubkey)
|
|
68
|
+
*
|
|
69
|
+
* // Instance-based verification
|
|
70
|
+
* const schnorr = new Schnorr({ privkey, hashbuf })
|
|
71
|
+
* schnorr.set({ sig, pubkey }).verify().verified
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
14
74
|
export declare class Schnorr {
|
|
75
|
+
/** 32-byte hash buffer to sign or verify */
|
|
15
76
|
hashbuf: Buffer;
|
|
77
|
+
/** Byte endianness for hash interpretation ('little' or 'big') */
|
|
16
78
|
endian: 'little' | 'big';
|
|
79
|
+
/** Private key for signing operations */
|
|
17
80
|
privkey: PrivateKey;
|
|
81
|
+
/** Public key for verification (auto-derived from privkey if not set) */
|
|
18
82
|
pubkey: PublicKey;
|
|
83
|
+
/** Schnorr signature object (generated by sign(), verified by verify()) */
|
|
19
84
|
sig: Signature;
|
|
85
|
+
/** Result of signature verification (true if valid, false if invalid) */
|
|
20
86
|
verified: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a new Schnorr signature instance
|
|
89
|
+
*
|
|
90
|
+
* @param obj - Optional initialization data for the instance
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const schnorr = new Schnorr({ hashbuf, privkey })
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
21
96
|
constructor(obj?: SchnorrData);
|
|
97
|
+
/**
|
|
98
|
+
* Sets instance properties from a data object
|
|
99
|
+
*
|
|
100
|
+
* This method allows chaining by returning 'this'. It intelligently
|
|
101
|
+
* derives the public key from the private key if pubkey is not provided.
|
|
102
|
+
*
|
|
103
|
+
* @param obj - Data object containing properties to set
|
|
104
|
+
* @returns This Schnorr instance for method chaining
|
|
105
|
+
*/
|
|
22
106
|
set(obj: SchnorrData): Schnorr;
|
|
107
|
+
/**
|
|
108
|
+
* Derive public key from the instance's private key
|
|
109
|
+
*
|
|
110
|
+
* Computes the corresponding public key from the private key using
|
|
111
|
+
* elliptic curve point multiplication: P = d*G where d is private key
|
|
112
|
+
* and G is the generator point.
|
|
113
|
+
*
|
|
114
|
+
* @returns This Schnorr instance for method chaining
|
|
115
|
+
* @throws Error if privkey is not set
|
|
116
|
+
*/
|
|
23
117
|
privkey2pubkey(): Schnorr;
|
|
118
|
+
/**
|
|
119
|
+
* Get the public key from the instance's private key
|
|
120
|
+
*
|
|
121
|
+
* Convenience method that returns the public key without modifying
|
|
122
|
+
* the instance state.
|
|
123
|
+
*
|
|
124
|
+
* @returns The public key derived from the private key
|
|
125
|
+
* @throws Error if privkey is not set
|
|
126
|
+
*/
|
|
24
127
|
toPublicKey(): PublicKey;
|
|
128
|
+
/**
|
|
129
|
+
* Sign the hash using Schnorr signature algorithm
|
|
130
|
+
*
|
|
131
|
+
* Performs the complete Schnorr signing process:
|
|
132
|
+
* 1. Validates inputs (32-byte hash, valid private key)
|
|
133
|
+
* 2. Converts hash to big number
|
|
134
|
+
* 3. Generates signature components using _findSignature()
|
|
135
|
+
* 4. Creates Signature object with Schnorr flag set
|
|
136
|
+
*
|
|
137
|
+
* @returns This Schnorr instance with the 'sig' property set
|
|
138
|
+
* @throws Error if hashbuf is not 32 bytes or privkey is invalid
|
|
139
|
+
*/
|
|
25
140
|
sign(): Schnorr;
|
|
141
|
+
/**
|
|
142
|
+
* Find signature values using Lotus Schnorr algorithm
|
|
143
|
+
*
|
|
144
|
+
* Process:
|
|
145
|
+
* 1. Generate deterministic nonce k using RFC6979 with "Schnorr+SHA256 " seed
|
|
146
|
+
* 2. Compute R = k*G
|
|
147
|
+
* 3. If R.y is not a quadratic residue, use n-k instead (negate)
|
|
148
|
+
* 4. Compute e = Hash(R.x || compressed(P) || m) mod n
|
|
149
|
+
* 5. Compute s = k + e*d mod n
|
|
150
|
+
* 6. Return signature (r=R.x, s)
|
|
151
|
+
*/
|
|
26
152
|
_findSignature(d: BN, e: BN): {
|
|
27
153
|
r: BN;
|
|
28
154
|
s: BN;
|
|
29
155
|
compressed?: boolean;
|
|
30
156
|
isSchnorr?: boolean;
|
|
31
157
|
};
|
|
158
|
+
/**
|
|
159
|
+
* Ensure r part of signature is at least 32 bytes
|
|
160
|
+
*
|
|
161
|
+
* The BN type naturally cuts off leading zeros, e.g.
|
|
162
|
+
* <BN: 4f92d8094f710bc11b93935ac157730dda26c5c2a856650dbd8ebcd730d2d4> 31 bytes
|
|
163
|
+
* Buffer <00 4f 92 d8 09 4f 71 0b c1 1b 93 93 5a c1 57 73 0d da 26 c5 c2 a8 56 65 0d bd 8e bc d7 30 d2 d4> 32 bytes
|
|
164
|
+
* Both types are equal, however Schnorr signatures must be a minimum of 64 bytes.
|
|
165
|
+
* This ensures the r component is always 32 bytes for proper signature formatting.
|
|
166
|
+
*
|
|
167
|
+
* @param r - The r value as BN
|
|
168
|
+
* @returns Buffer representation (at least 32 bytes, big-endian)
|
|
169
|
+
*/
|
|
32
170
|
private getrBuffer;
|
|
171
|
+
/**
|
|
172
|
+
* Check for signature errors (verification)
|
|
173
|
+
*
|
|
174
|
+
* Lotus Schnorr Verification:
|
|
175
|
+
* 1. Check signature length is 64 or 65 bytes (65 with sighash byte)
|
|
176
|
+
* 2. Check r < p (field prime) and s < n (curve order)
|
|
177
|
+
* 3. Compute e = Hash(r || compressed(P) || m) mod n
|
|
178
|
+
* 4. Compute R = s*G - e*P
|
|
179
|
+
* 5. Check R is not infinity
|
|
180
|
+
* 6. Check R.y is a quadratic residue
|
|
181
|
+
* 7. Check R.x == r
|
|
182
|
+
*
|
|
183
|
+
* @returns True if verification fails (signature is invalid), false if signature is valid
|
|
184
|
+
*/
|
|
33
185
|
sigError(): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Verify signature
|
|
188
|
+
*
|
|
189
|
+
* Performs Schnorr signature verification and stores the result
|
|
190
|
+
* in the 'verified' property. Uses sigError() internally.
|
|
191
|
+
*
|
|
192
|
+
* @returns This Schnorr instance with 'verified' property set to the verification result
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const isValid = schnorr.set({ hashbuf, sig, pubkey }).verify().verified
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
34
198
|
verify(): Schnorr;
|
|
199
|
+
/**
|
|
200
|
+
* RFC6979 deterministic nonce generation for Lotus Schnorr
|
|
201
|
+
*
|
|
202
|
+
* Uses HMAC-DRBG with SHA256 and Schnorr-specific domain separator.
|
|
203
|
+
*
|
|
204
|
+
* Key difference from standard RFC6979:
|
|
205
|
+
* - Uses "Schnorr+SHA256 " (with trailing spaces) as the algorithm identifier
|
|
206
|
+
* - This ensures different nonces than ECDSA for the same key and message
|
|
207
|
+
*
|
|
208
|
+
* Reference: lotusd/src/secp256k1/src/modules/schnorr/schnorr_impl.h
|
|
209
|
+
*/
|
|
35
210
|
nonceFunctionRFC6979(privkey: Buffer, msgbuf: Buffer): BN;
|
|
211
|
+
/**
|
|
212
|
+
* Static sign method
|
|
213
|
+
*
|
|
214
|
+
* @param hashbuf - 32-byte hash buffer to sign
|
|
215
|
+
* @param privkey - Private key for signing
|
|
216
|
+
* @param endian - Byte endianness ('little' or 'big')
|
|
217
|
+
* @returns Schnorr signature
|
|
218
|
+
*/
|
|
36
219
|
static sign(hashbuf: Buffer, privkey: PrivateKey, endian?: 'little' | 'big'): Signature;
|
|
220
|
+
/**
|
|
221
|
+
* Static verify method
|
|
222
|
+
*
|
|
223
|
+
* @param hashbuf - 32-byte hash buffer that was signed
|
|
224
|
+
* @param sig - Signature to verify
|
|
225
|
+
* @param pubkey - Public key to verify against
|
|
226
|
+
* @param endian - Byte endianness ('little' or 'big')
|
|
227
|
+
* @returns True if signature is valid, false otherwise
|
|
228
|
+
*/
|
|
37
229
|
static verify(hashbuf: Buffer, sig: Signature, pubkey: PublicKey, endian?: 'little' | 'big'): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Reverse buffer byte order
|
|
232
|
+
*
|
|
233
|
+
* Used for converting between little-endian and big-endian representations
|
|
234
|
+
* of hash values. This is needed when interpreting hashes with different
|
|
235
|
+
* endianness conventions.
|
|
236
|
+
*
|
|
237
|
+
* @param buf - Buffer to reverse
|
|
238
|
+
* @returns New buffer with bytes in reversed order
|
|
239
|
+
* @private
|
|
240
|
+
*/
|
|
38
241
|
private reverseBuffer;
|
|
39
242
|
}
|
|
40
243
|
//# sourceMappingURL=schnorr.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schnorr.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/crypto/schnorr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schnorr.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/crypto/schnorr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAA;IACzB,yCAAyC;IACzC,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,kCAAkC;IAClC,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,+BAA+B;IAC/B,GAAG,CAAC,EAAE,SAAS,CAAA;IACf,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,OAAO;IAClB,4CAA4C;IAC5C,OAAO,EAAG,MAAM,CAAA;IAChB,kEAAkE;IAClE,MAAM,EAAG,QAAQ,GAAG,KAAK,CAAA;IACzB,yCAAyC;IACzC,OAAO,EAAG,UAAU,CAAA;IACpB,yEAAyE;IACzE,MAAM,EAAG,SAAS,CAAA;IAClB,2EAA2E;IAC3E,GAAG,EAAG,SAAS,CAAA;IACf,yEAAyE;IACzE,QAAQ,EAAG,OAAO,CAAA;IAElB;;;;;;;;OAQG;gBACS,GAAG,CAAC,EAAE,WAAW;IAM7B;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO;IAW9B;;;;;;;;;OASG;IACH,cAAc,IAAI,OAAO;IAKzB;;;;;;;;OAQG;IACH,WAAW,IAAI,SAAS;IAIxB;;;;;;;;;;;OAWG;IACH,IAAI,IAAI,OAAO;IAuBf;;;;;;;;;;OAUG;IACH,cAAc,CACZ,CAAC,EAAE,EAAE,EACL,CAAC,EAAE,EAAE,GACJ;QAAE,CAAC,EAAE,EAAE,CAAC;QAAC,CAAC,EAAE,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAqD9D;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,UAAU;IAKlB;;;;;;;;;;;;;OAaG;IACH,QAAQ,IAAI,OAAO;IAmDnB;;;;;;;;;;;OAWG;IACH,MAAM,IAAI,OAAO;IAKjB;;;;;;;;;;OAUG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,EAAE;IAkEzD;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CACT,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,UAAU,EACnB,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,GACxB,SAAS;IAUZ;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,CACX,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,SAAS,EACjB,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,GACxB,OAAO;IAWV;;;;;;;;;;OAUG;IACH,OAAO,CAAC,aAAa;CAOtB"}
|