@btc-vision/transaction 1.6.18 → 1.7.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/browser/index.js +1 -1
- package/browser/index.js.LICENSE.txt +2 -0
- package/browser/src/_version.d.ts +1 -0
- package/browser/{epoch → src/epoch}/interfaces/IChallengeSolution.d.ts +2 -0
- package/browser/{keypair → src/keypair}/Address.d.ts +7 -4
- package/browser/{keypair → src/keypair}/AddressVerificator.d.ts +3 -0
- package/browser/{keypair → src/keypair}/EcKeyPair.d.ts +3 -2
- package/browser/{keypair → src/keypair}/MessageSigner.d.ts +9 -0
- package/browser/src/keypair/Wallet.d.ts +47 -0
- package/browser/{keypair → src/keypair}/interfaces/IWallet.d.ts +2 -0
- package/browser/src/mnemonic/Mnemonic.d.ts +29 -0
- package/browser/src/mnemonic/MnemonicStrength.d.ts +7 -0
- package/browser/{opnet.d.ts → src/opnet.d.ts} +4 -0
- package/browser/src/transaction/browser/types/OPWallet.d.ts +14 -0
- package/browser/test/address.test.d.ts +1 -0
- package/browser/test/addressverificator-mldsa.test.d.ts +1 -0
- package/browser/test/derivePath.test.d.ts +1 -0
- package/browser/test/messagesigner-mldsa.test.d.ts +1 -0
- package/browser/test/messagesigner-schnorr.test.d.ts +1 -0
- package/browser/test/network-awareness.test.d.ts +1 -0
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/crypto/crypto-browser.d.ts +11 -0
- package/build/crypto/crypto-browser.js +56 -0
- package/build/epoch/ChallengeSolution.js +3 -2
- package/build/epoch/interfaces/IChallengeSolution.d.ts +2 -0
- package/build/keypair/Address.d.ts +7 -4
- package/build/keypair/Address.js +88 -37
- package/build/keypair/AddressVerificator.d.ts +3 -0
- package/build/keypair/AddressVerificator.js +49 -1
- package/build/keypair/EcKeyPair.d.ts +3 -2
- package/build/keypair/EcKeyPair.js +17 -3
- package/build/keypair/MessageSigner.d.ts +9 -0
- package/build/keypair/MessageSigner.js +23 -0
- package/build/keypair/Wallet.d.ts +20 -3
- package/build/keypair/Wallet.js +108 -9
- package/build/keypair/interfaces/IWallet.d.ts +2 -0
- package/build/mnemonic/Mnemonic.d.ts +29 -0
- package/build/mnemonic/Mnemonic.js +98 -0
- package/build/mnemonic/MnemonicStrength.d.ts +7 -0
- package/build/mnemonic/MnemonicStrength.js +8 -0
- package/build/opnet.d.ts +4 -0
- package/build/opnet.js +4 -0
- package/build/transaction/browser/types/OPWallet.d.ts +14 -0
- package/build/transaction/browser/types/OPWallet.js +6 -0
- package/gulpfile.js +2 -2
- package/package.json +28 -20
- package/src/_version.ts +1 -1
- package/src/epoch/ChallengeSolution.ts +3 -2
- package/src/epoch/interfaces/IChallengeSolution.ts +2 -0
- package/src/keypair/Address.ts +145 -43
- package/src/keypair/AddressVerificator.ts +87 -2
- package/src/keypair/EcKeyPair.ts +58 -6
- package/src/keypair/MessageSigner.ts +58 -0
- package/src/keypair/Wallet.ts +339 -57
- package/src/keypair/interfaces/IWallet.ts +13 -3
- package/src/mnemonic/Mnemonic.ts +340 -0
- package/src/mnemonic/MnemonicStrength.ts +12 -0
- package/src/network/ChainId.ts +1 -4
- package/src/opnet.ts +16 -0
- package/src/transaction/browser/types/OPWallet.ts +73 -0
- package/test/address.test.ts +1068 -0
- package/test/addressverificator-mldsa.test.ts +473 -0
- package/test/derivePath.test.ts +234 -0
- package/test/messagesigner-mldsa.test.ts +1060 -0
- package/test/messagesigner-schnorr.test.ts +1011 -0
- package/test/network-awareness.test.ts +163 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +21 -0
- package/browser/_version.d.ts +0 -1
- package/browser/keypair/Wallet.d.ts +0 -30
- /package/browser/{abi → src/abi}/ABICoder.d.ts +0 -0
- /package/browser/{buffer → src/buffer}/BinaryReader.d.ts +0 -0
- /package/browser/{buffer → src/buffer}/BinaryWriter.d.ts +0 -0
- /package/browser/{bytecode → src/bytecode}/Compressor.d.ts +0 -0
- /package/browser/{consensus → src/consensus}/Consensus.d.ts +0 -0
- /package/browser/{consensus → src/consensus}/ConsensusConfig.d.ts +0 -0
- /package/browser/{consensus → src/consensus}/metadata/RoswellConsensus.d.ts +0 -0
- /package/browser/{crypto → src/crypto}/crypto-browser.d.ts +0 -0
- /package/browser/{crypto → src/crypto}/crypto.d.ts +0 -0
- /package/browser/{deterministic → src/deterministic}/AddressMap.d.ts +0 -0
- /package/browser/{deterministic → src/deterministic}/AddressSet.d.ts +0 -0
- /package/browser/{deterministic → src/deterministic}/DeterministicMap.d.ts +0 -0
- /package/browser/{deterministic → src/deterministic}/DeterministicSet.d.ts +0 -0
- /package/browser/{deterministic → src/deterministic}/Map.d.ts +0 -0
- /package/browser/{epoch → src/epoch}/ChallengeSolution.d.ts +0 -0
- /package/browser/{epoch → src/epoch}/validator/EpochValidator.d.ts +0 -0
- /package/browser/{event → src/event}/NetEvent.d.ts +0 -0
- /package/browser/{generators → src/generators}/AddressGenerator.d.ts +0 -0
- /package/browser/{generators → src/generators}/Features.d.ts +0 -0
- /package/browser/{generators → src/generators}/Generator.d.ts +0 -0
- /package/browser/{generators → src/generators}/builders/CalldataGenerator.d.ts +0 -0
- /package/browser/{generators → src/generators}/builders/CustomGenerator.d.ts +0 -0
- /package/browser/{generators → src/generators}/builders/DeploymentGenerator.d.ts +0 -0
- /package/browser/{generators → src/generators}/builders/LegacyCalldataGenerator.d.ts +0 -0
- /package/browser/{generators → src/generators}/builders/MultiSignGenerator.d.ts +0 -0
- /package/browser/{generators → src/generators}/builders/P2WDAGenerator.d.ts +0 -0
- /package/browser/{index.d.ts → src/index.d.ts} +0 -0
- /package/browser/{keypair → src/keypair}/Secp256k1PointDeriver.d.ts +0 -0
- /package/browser/{metadata → src/metadata}/ContractBaseMetadata.d.ts +0 -0
- /package/browser/{metadata → src/metadata}/tokens.d.ts +0 -0
- /package/browser/{network → src/network}/ChainId.d.ts +0 -0
- /package/browser/{p2wda → src/p2wda}/P2WDADetector.d.ts +0 -0
- /package/browser/{signer → src/signer}/SignerUtils.d.ts +0 -0
- /package/browser/{signer → src/signer}/TweakedSigner.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/ContractAddress.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/TransactionFactory.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/browser/BrowserSignerBase.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/browser/Web3Provider.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/browser/extensions/UnisatSigner.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/browser/extensions/XverseSigner.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/browser/types/Unisat.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/browser/types/Xverse.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/CancelTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/ChallengeSolutionTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/CustomScriptTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/DeploymentTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/FundingTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/InteractionTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/InteractionTransactionP2WDA.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/MultiSignTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/SharedInteractionTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/builders/TransactionBuilder.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/enums/TransactionType.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/interfaces/ITransactionParameters.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/interfaces/Tap.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/mineable/IP2WSHAddress.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/mineable/TimelockGenerator.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/processor/PsbtTransaction.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/psbt/PSBTTypes.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/shared/P2TR_MS.d.ts +0 -0
- /package/browser/{transaction → src/transaction}/shared/TweakedTransaction.d.ts +0 -0
- /package/browser/{utils → src/utils}/BitcoinUtils.d.ts +0 -0
- /package/browser/{utils → src/utils}/BufferHelper.d.ts +0 -0
- /package/browser/{utils → src/utils}/StringToBuffer.d.ts +0 -0
- /package/browser/{utils → src/utils}/lengths.d.ts +0 -0
- /package/browser/{utils → src/utils}/types.d.ts +0 -0
- /package/browser/{utxo → src/utxo}/OPNetLimitedProvider.d.ts +0 -0
- /package/browser/{utxo → src/utxo}/interfaces/BroadcastResponse.d.ts +0 -0
- /package/browser/{utxo → src/utxo}/interfaces/IUTXO.d.ts +0 -0
- /package/browser/{verification → src/verification}/TapscriptVerificator.d.ts +0 -0
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
22
22
|
|
|
23
|
+
/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */
|
|
24
|
+
|
|
23
25
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
24
26
|
|
|
25
27
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "1.7.0";
|
|
@@ -27,6 +27,7 @@ export interface RawChallengeVerification {
|
|
|
27
27
|
readonly proofs: readonly string[];
|
|
28
28
|
}
|
|
29
29
|
export interface RawChallengeSubmission {
|
|
30
|
+
readonly classicPublicKey: string;
|
|
30
31
|
readonly publicKey: string;
|
|
31
32
|
readonly solution: string;
|
|
32
33
|
readonly graffiti?: string;
|
|
@@ -40,6 +41,7 @@ export interface IChallengeSubmission {
|
|
|
40
41
|
}
|
|
41
42
|
export interface RawChallenge {
|
|
42
43
|
readonly epochNumber: string;
|
|
44
|
+
readonly classicPublicKey: string;
|
|
43
45
|
readonly publicKey: string;
|
|
44
46
|
readonly solution: string;
|
|
45
47
|
readonly salt: string;
|
|
@@ -2,16 +2,19 @@ import { Network } from '@btc-vision/bitcoin';
|
|
|
2
2
|
import { IP2WSHAddress } from '../transaction/mineable/IP2WSHAddress.js';
|
|
3
3
|
export declare class Address extends Uint8Array {
|
|
4
4
|
#private;
|
|
5
|
-
|
|
5
|
+
private classicPublicKey;
|
|
6
|
+
constructor(mldsaPublicKey?: ArrayLike<number>, publicKeyOrTweak?: ArrayLike<number>);
|
|
6
7
|
get originalPublicKey(): Uint8Array | undefined;
|
|
8
|
+
get mldsaPublicKey(): Uint8Array | undefined;
|
|
7
9
|
private get keyPair();
|
|
8
10
|
static dead(): Address;
|
|
9
|
-
static
|
|
10
|
-
static fromString(pubKey: string): Address;
|
|
11
|
+
static fromString(mldsaPublicKey: string, classicPublicKey?: string): Address;
|
|
11
12
|
static wrap(bytes: ArrayLike<number>): Address;
|
|
12
13
|
static uncompressedToCompressed(publicKey: ArrayLike<number>): Buffer;
|
|
13
14
|
toHex(): string;
|
|
15
|
+
tweakedToHex(): string;
|
|
14
16
|
toBuffer(): Buffer;
|
|
17
|
+
tweakedPublicKeyToBuffer(): Buffer;
|
|
15
18
|
toUncompressedHex(): string;
|
|
16
19
|
toUncompressedBuffer(): Buffer;
|
|
17
20
|
toHybridPublicKeyHex(): string;
|
|
@@ -20,7 +23,7 @@ export declare class Address extends Uint8Array {
|
|
|
20
23
|
equals(a: Address): boolean;
|
|
21
24
|
lessThan(a: Address): boolean;
|
|
22
25
|
greaterThan(a: Address): boolean;
|
|
23
|
-
set(
|
|
26
|
+
set(mldsaPublicKey: ArrayLike<number>): void;
|
|
24
27
|
isValid(network: Network): boolean;
|
|
25
28
|
p2pk(): string;
|
|
26
29
|
p2wpkh(network: Network): string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Network } from '@btc-vision/bitcoin';
|
|
2
|
+
import { MLDSASecurityLevel } from '@btc-vision/bip32';
|
|
2
3
|
export declare enum AddressTypes {
|
|
3
4
|
P2PKH = "P2PKH",
|
|
4
5
|
P2OP = "P2OP",
|
|
@@ -22,6 +23,8 @@ export declare class AddressVerificator {
|
|
|
22
23
|
static isP2WDAWitnessScript(witnessScript: Buffer): boolean;
|
|
23
24
|
static isP2PKHOrP2SH(addy: string, network: Network): boolean;
|
|
24
25
|
static isValidPublicKey(input: string, network: Network): boolean;
|
|
26
|
+
static isValidMLDSAPublicKey(input: string | Buffer | Uint8Array): MLDSASecurityLevel | null;
|
|
27
|
+
static isValidP2OPAddress(inAddress: string, network: Network): boolean;
|
|
25
28
|
static requireRedeemScript(addy: string, network: Network): boolean;
|
|
26
29
|
static detectAddressType(addy: string, network: Network): AddressTypes | null;
|
|
27
30
|
static detectAddressTypeWithWitnessScript(addy: string, network: Network, witnessScript?: Buffer): AddressTypes | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BIP32API, BIP32Interface } from 'bip32';
|
|
1
|
+
import { BIP32API, BIP32Interface, MLDSAKeyPair, MLDSASecurityLevel } from '@btc-vision/bip32';
|
|
2
2
|
import { Network, Signer } from '@btc-vision/bitcoin';
|
|
3
3
|
import { ECPairAPI, ECPairInterface } from 'ecpair';
|
|
4
4
|
import { IWallet } from './interfaces/IWallet.js';
|
|
@@ -17,7 +17,8 @@ export declare class EcKeyPair {
|
|
|
17
17
|
static xOnlyTweakedPubKeyToAddress(tweakedPubKeyHex: string, network: Network): string;
|
|
18
18
|
static tweakPublicKey(pub: Uint8Array | Buffer | string): Buffer;
|
|
19
19
|
static tweakBatchSharedT(pubkeys: readonly Uint8Array[], tweakScalar: bigint): Uint8Array[];
|
|
20
|
-
static generateWallet(network?: Network): IWallet;
|
|
20
|
+
static generateWallet(network?: Network, securityLevel?: MLDSASecurityLevel): IWallet;
|
|
21
|
+
static generateQuantumKeyPair(securityLevel?: MLDSASecurityLevel, network?: Network): MLDSAKeyPair;
|
|
21
22
|
static verifyContractAddress(contractAddress: string, network?: Network): boolean;
|
|
22
23
|
static getLegacySegwitAddress(keyPair: ECPairInterface, network?: Network): string;
|
|
23
24
|
static getLegacyAddress(keyPair: ECPairInterface, network?: Network): string;
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { ECPairInterface } from 'ecpair';
|
|
2
2
|
import { Network } from '@btc-vision/bitcoin';
|
|
3
|
+
import { MLDSASecurityLevel, QuantumBIP32Interface } from '@btc-vision/bip32';
|
|
3
4
|
export interface SignedMessage {
|
|
4
5
|
readonly signature: Uint8Array;
|
|
5
6
|
readonly message: Uint8Array;
|
|
6
7
|
}
|
|
8
|
+
export interface MLDSASignedMessage {
|
|
9
|
+
readonly signature: Uint8Array;
|
|
10
|
+
readonly message: Uint8Array;
|
|
11
|
+
readonly publicKey: Uint8Array;
|
|
12
|
+
readonly securityLevel: MLDSASecurityLevel;
|
|
13
|
+
}
|
|
7
14
|
declare class MessageSignerBase {
|
|
8
15
|
sha256(message: Buffer | Uint8Array): Buffer;
|
|
9
16
|
tweakAndSignMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string, network: Network): SignedMessage;
|
|
10
17
|
signMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string): SignedMessage;
|
|
11
18
|
verifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
|
|
12
19
|
tweakAndVerifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
|
|
20
|
+
signMLDSAMessage(mldsaKeypair: QuantumBIP32Interface, message: Uint8Array | Buffer | string): MLDSASignedMessage;
|
|
21
|
+
verifyMLDSASignature(mldsaKeypair: QuantumBIP32Interface, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
|
|
13
22
|
}
|
|
14
23
|
export declare const MessageSigner: MessageSignerBase;
|
|
15
24
|
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ECPairInterface } from 'ecpair';
|
|
2
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
3
|
+
import { Address } from './Address.js';
|
|
4
|
+
import { IP2WSHAddress } from '../transaction/mineable/IP2WSHAddress.js';
|
|
5
|
+
import { MLDSASecurityLevel, QuantumBIP32Interface } from '@btc-vision/bip32';
|
|
6
|
+
export declare class Wallet {
|
|
7
|
+
readonly network: Network;
|
|
8
|
+
private readonly _keypair;
|
|
9
|
+
private readonly _mldsaKeypair;
|
|
10
|
+
private readonly _securityLevel;
|
|
11
|
+
private readonly _chainCode;
|
|
12
|
+
private readonly _p2wpkh;
|
|
13
|
+
private readonly _p2tr;
|
|
14
|
+
private readonly _p2wda;
|
|
15
|
+
private readonly _legacy;
|
|
16
|
+
private readonly _segwitLegacy;
|
|
17
|
+
private readonly _bufferPubKey;
|
|
18
|
+
private readonly _tweakedKey;
|
|
19
|
+
private readonly _address;
|
|
20
|
+
constructor(privateKeyOrWif: string, mldsaPrivateKeyOrBase58: string, network?: Network, securityLevel?: MLDSASecurityLevel, chainCode?: Buffer);
|
|
21
|
+
get address(): Address;
|
|
22
|
+
get tweakedPubKeyKey(): Buffer;
|
|
23
|
+
get keypair(): ECPairInterface;
|
|
24
|
+
get mldsaKeypair(): QuantumBIP32Interface;
|
|
25
|
+
get securityLevel(): MLDSASecurityLevel;
|
|
26
|
+
get chainCode(): Buffer;
|
|
27
|
+
get p2wpkh(): string;
|
|
28
|
+
get p2tr(): string;
|
|
29
|
+
get p2wda(): IP2WSHAddress;
|
|
30
|
+
get legacy(): string;
|
|
31
|
+
get addresses(): string[];
|
|
32
|
+
get segwitLegacy(): string;
|
|
33
|
+
get publicKey(): Buffer;
|
|
34
|
+
get quantumPublicKey(): Buffer;
|
|
35
|
+
get quantumPrivateKey(): Buffer;
|
|
36
|
+
get quantumPublicKeyHex(): string;
|
|
37
|
+
get quantumPrivateKeyHex(): string;
|
|
38
|
+
get xOnly(): Buffer;
|
|
39
|
+
static fromWif(wif: string, quantumPrivateKeyHex: string, network?: Network, securityLevel?: MLDSASecurityLevel, chainCode?: Buffer): Wallet;
|
|
40
|
+
static generate(network?: Network, securityLevel?: MLDSASecurityLevel): Wallet;
|
|
41
|
+
static fromPrivateKeys(privateKeyHexOrWif: string, mldsaPrivateKeyOrBase58: string, network?: Network, securityLevel?: MLDSASecurityLevel, chainCode?: Buffer): Wallet;
|
|
42
|
+
toWIF(): string;
|
|
43
|
+
toPrivateKeyHex(): string;
|
|
44
|
+
toPublicKeyHex(): string;
|
|
45
|
+
toQuantumBase58(): string;
|
|
46
|
+
derivePath(path: string): Wallet;
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BIP32Interface, MLDSASecurityLevel, QuantumBIP32Interface } from '@btc-vision/bip32';
|
|
2
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
3
|
+
import { Wallet } from '../keypair/Wallet.js';
|
|
4
|
+
import { MnemonicStrength } from './MnemonicStrength.js';
|
|
5
|
+
export declare class Mnemonic {
|
|
6
|
+
private readonly _phrase;
|
|
7
|
+
private readonly _passphrase;
|
|
8
|
+
private readonly _network;
|
|
9
|
+
private readonly _securityLevel;
|
|
10
|
+
private readonly _seed;
|
|
11
|
+
private readonly _classicalRoot;
|
|
12
|
+
private readonly _quantumRoot;
|
|
13
|
+
constructor(phrase: string, passphrase?: string, network?: Network, securityLevel?: MLDSASecurityLevel);
|
|
14
|
+
get phrase(): string;
|
|
15
|
+
get network(): Network;
|
|
16
|
+
get securityLevel(): MLDSASecurityLevel;
|
|
17
|
+
get seed(): Buffer;
|
|
18
|
+
static generatePhrase(strength?: MnemonicStrength): string;
|
|
19
|
+
static generate(strength?: MnemonicStrength, passphrase?: string, network?: Network, securityLevel?: MLDSASecurityLevel): Mnemonic;
|
|
20
|
+
static validate(phrase: string): boolean;
|
|
21
|
+
derive(index?: number, account?: number, isChange?: boolean): Wallet;
|
|
22
|
+
deriveMultiple(count: number, startIndex?: number, account?: number, isChange?: boolean): Wallet[];
|
|
23
|
+
deriveCustomPath(classicalPath: string, quantumPath: string): Wallet;
|
|
24
|
+
getClassicalRoot(): BIP32Interface;
|
|
25
|
+
getQuantumRoot(): QuantumBIP32Interface;
|
|
26
|
+
private buildClassicalPath;
|
|
27
|
+
private buildQuantumPath;
|
|
28
|
+
private getCoinType;
|
|
29
|
+
}
|
|
@@ -19,6 +19,9 @@ export * from './keypair/EcKeyPair.js';
|
|
|
19
19
|
export * from './keypair/interfaces/IWallet.js';
|
|
20
20
|
export * from './keypair/MessageSigner.js';
|
|
21
21
|
export * from './keypair/Wallet.js';
|
|
22
|
+
export * from './mnemonic/Mnemonic.js';
|
|
23
|
+
export * from './mnemonic/MnemonicStrength.js';
|
|
24
|
+
export { MLDSASecurityLevel, MLDSAKeyPair, QuantumBIP32Interface, QuantumBIP32API, QuantumSigner, QuantumBIP32Factory, QuantumDerivationPath, } from '@btc-vision/bip32';
|
|
22
25
|
export * from './metadata/ContractBaseMetadata.js';
|
|
23
26
|
export * from './network/ChainId.js';
|
|
24
27
|
export * from './signer/TweakedSigner.js';
|
|
@@ -66,6 +69,7 @@ export * from './transaction/browser/extensions/UnisatSigner.js';
|
|
|
66
69
|
export * from './transaction/browser/extensions/XverseSigner.js';
|
|
67
70
|
export * from './transaction/browser/types/Unisat.js';
|
|
68
71
|
export * from './transaction/browser/types/Xverse.js';
|
|
72
|
+
export * from './transaction/browser/types/OPWallet.js';
|
|
69
73
|
export * from './metadata/tokens.js';
|
|
70
74
|
export * from './transaction/browser/Web3Provider.js';
|
|
71
75
|
export * from './keypair/Secp256k1PointDeriver.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Unisat } from './Unisat.js';
|
|
2
|
+
import { MLDSASecurityLevel } from '@btc-vision/bip32';
|
|
3
|
+
export interface MLDSASignature {
|
|
4
|
+
readonly signature: string;
|
|
5
|
+
readonly publicKey: string;
|
|
6
|
+
readonly securityLevel: MLDSASecurityLevel;
|
|
7
|
+
readonly messageHash: string;
|
|
8
|
+
}
|
|
9
|
+
export interface OPWallet extends Unisat {
|
|
10
|
+
getMLDSAPublicKey(): Promise<string>;
|
|
11
|
+
signMLDSAMessage(message: string): Promise<MLDSASignature>;
|
|
12
|
+
verifyMLDSASignature(message: string, signature: MLDSASignature): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
export declare function isOPWallet(wallet: unknown): wallet is OPWallet;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.7.0";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.
|
|
1
|
+
export const version = '1.7.0';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function createHash(algo: any): import("@noble/hashes/utils").Hash<import("@noble/hashes/utils").Hash<any>> | undefined;
|
|
2
|
+
export function createHmac(_algo: any, key: any): import("@noble/hashes/hmac").HMAC<any>;
|
|
3
|
+
export function pbkdf2Sync(password: any, salt: any, iterations: any, keylen: any, _algo: any): Uint8Array<ArrayBufferLike>;
|
|
4
|
+
export function randomBytes(length: any): Uint8Array<any>;
|
|
5
|
+
declare namespace _default {
|
|
6
|
+
export { createHash };
|
|
7
|
+
export { createHmac };
|
|
8
|
+
export { pbkdf2Sync };
|
|
9
|
+
export { randomBytes };
|
|
10
|
+
}
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { hmac } from '@noble/hashes/hmac';
|
|
2
|
+
import { pbkdf2 } from '@noble/hashes/pbkdf2';
|
|
3
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
4
|
+
import { sha512 } from '@noble/hashes/sha512';
|
|
5
|
+
import assert from 'assert';
|
|
6
|
+
function assertArgument(check, message, name, value) {
|
|
7
|
+
assert(check, message, 'INVALID_ARGUMENT', { argument: name, value: value });
|
|
8
|
+
}
|
|
9
|
+
function getGlobal() {
|
|
10
|
+
if (typeof self !== 'undefined') {
|
|
11
|
+
return self;
|
|
12
|
+
}
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
return window;
|
|
15
|
+
}
|
|
16
|
+
if (typeof global !== 'undefined') {
|
|
17
|
+
return global;
|
|
18
|
+
}
|
|
19
|
+
throw new Error('unable to locate global object');
|
|
20
|
+
}
|
|
21
|
+
const anyGlobal = getGlobal();
|
|
22
|
+
const crypto = anyGlobal.crypto || anyGlobal.msCrypto;
|
|
23
|
+
export function createHash(algo) {
|
|
24
|
+
switch (algo) {
|
|
25
|
+
case 'sha256':
|
|
26
|
+
return sha256.create();
|
|
27
|
+
case 'sha512':
|
|
28
|
+
return sha512.create();
|
|
29
|
+
}
|
|
30
|
+
assertArgument(false, 'invalid hashing algorithm name', 'algorithm', algo);
|
|
31
|
+
}
|
|
32
|
+
export function createHmac(_algo, key) {
|
|
33
|
+
const algo = { sha256, sha512 }[_algo];
|
|
34
|
+
assertArgument(algo != null, 'invalid hmac algorithm', 'algorithm', _algo);
|
|
35
|
+
return hmac.create(algo, key);
|
|
36
|
+
}
|
|
37
|
+
export function pbkdf2Sync(password, salt, iterations, keylen, _algo) {
|
|
38
|
+
const algo = { sha256, sha512 }[_algo];
|
|
39
|
+
assertArgument(algo != null, 'invalid pbkdf2 algorithm', 'algorithm', _algo);
|
|
40
|
+
return pbkdf2(algo, password, salt, { c: iterations, dkLen: keylen });
|
|
41
|
+
}
|
|
42
|
+
export function randomBytes(length) {
|
|
43
|
+
assert(crypto != null, 'platform does not support secure random numbers', 'UNSUPPORTED_OPERATION', {
|
|
44
|
+
operation: 'randomBytes',
|
|
45
|
+
});
|
|
46
|
+
assertArgument(Number.isInteger(length) && length > 0 && length <= 1024, 'invalid length', 'length', length);
|
|
47
|
+
const result = new Uint8Array(length);
|
|
48
|
+
crypto.getRandomValues(result);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
export default {
|
|
52
|
+
createHash,
|
|
53
|
+
createHmac,
|
|
54
|
+
pbkdf2Sync,
|
|
55
|
+
randomBytes,
|
|
56
|
+
};
|
|
@@ -17,7 +17,7 @@ export class ChallengeVerification {
|
|
|
17
17
|
export class ChallengeSubmission {
|
|
18
18
|
constructor(data, epochNumber) {
|
|
19
19
|
this.epochNumber = epochNumber;
|
|
20
|
-
this.publicKey = Address.fromString(data.publicKey);
|
|
20
|
+
this.publicKey = Address.fromString(data.publicKey, data.classicPublicKey);
|
|
21
21
|
this.solution = stringToBuffer(data.solution);
|
|
22
22
|
this.graffiti = data.graffiti ? stringToBuffer(data.graffiti) : undefined;
|
|
23
23
|
this.signature = stringToBuffer(data.signature);
|
|
@@ -37,7 +37,7 @@ export class ChallengeSubmission {
|
|
|
37
37
|
export class ChallengeSolution {
|
|
38
38
|
constructor(data) {
|
|
39
39
|
this.epochNumber = BigInt(data.epochNumber);
|
|
40
|
-
this.publicKey = Address.fromString(data.publicKey);
|
|
40
|
+
this.publicKey = Address.fromString(data.publicKey, data.classicPublicKey);
|
|
41
41
|
this.solution = stringToBuffer(data.solution);
|
|
42
42
|
this.salt = stringToBuffer(data.salt);
|
|
43
43
|
this.graffiti = stringToBuffer(data.graffiti);
|
|
@@ -78,6 +78,7 @@ export class ChallengeSolution {
|
|
|
78
78
|
return {
|
|
79
79
|
epochNumber: this.epochNumber.toString(),
|
|
80
80
|
publicKey: this.publicKey.toHex(),
|
|
81
|
+
classicPublicKey: this.publicKey.tweakedToHex(),
|
|
81
82
|
solution: this.toHex(),
|
|
82
83
|
salt: '0x' + this.salt.toString('hex'),
|
|
83
84
|
graffiti: '0x' + this.graffiti.toString('hex'),
|
|
@@ -27,6 +27,7 @@ export interface RawChallengeVerification {
|
|
|
27
27
|
readonly proofs: readonly string[];
|
|
28
28
|
}
|
|
29
29
|
export interface RawChallengeSubmission {
|
|
30
|
+
readonly classicPublicKey: string;
|
|
30
31
|
readonly publicKey: string;
|
|
31
32
|
readonly solution: string;
|
|
32
33
|
readonly graffiti?: string;
|
|
@@ -40,6 +41,7 @@ export interface IChallengeSubmission {
|
|
|
40
41
|
}
|
|
41
42
|
export interface RawChallenge {
|
|
42
43
|
readonly epochNumber: string;
|
|
44
|
+
readonly classicPublicKey: string;
|
|
43
45
|
readonly publicKey: string;
|
|
44
46
|
readonly solution: string;
|
|
45
47
|
readonly salt: string;
|
|
@@ -2,16 +2,19 @@ import { Network } from '@btc-vision/bitcoin';
|
|
|
2
2
|
import { IP2WSHAddress } from '../transaction/mineable/IP2WSHAddress.js';
|
|
3
3
|
export declare class Address extends Uint8Array {
|
|
4
4
|
#private;
|
|
5
|
-
|
|
5
|
+
private classicPublicKey;
|
|
6
|
+
constructor(mldsaPublicKey?: ArrayLike<number>, publicKeyOrTweak?: ArrayLike<number>);
|
|
6
7
|
get originalPublicKey(): Uint8Array | undefined;
|
|
8
|
+
get mldsaPublicKey(): Uint8Array | undefined;
|
|
7
9
|
private get keyPair();
|
|
8
10
|
static dead(): Address;
|
|
9
|
-
static
|
|
10
|
-
static fromString(pubKey: string): Address;
|
|
11
|
+
static fromString(mldsaPublicKey: string, classicPublicKey?: string): Address;
|
|
11
12
|
static wrap(bytes: ArrayLike<number>): Address;
|
|
12
13
|
static uncompressedToCompressed(publicKey: ArrayLike<number>): Buffer;
|
|
13
14
|
toHex(): string;
|
|
15
|
+
tweakedToHex(): string;
|
|
14
16
|
toBuffer(): Buffer;
|
|
17
|
+
tweakedPublicKeyToBuffer(): Buffer;
|
|
15
18
|
toUncompressedHex(): string;
|
|
16
19
|
toUncompressedBuffer(): Buffer;
|
|
17
20
|
toHybridPublicKeyHex(): string;
|
|
@@ -20,7 +23,7 @@ export declare class Address extends Uint8Array {
|
|
|
20
23
|
equals(a: Address): boolean;
|
|
21
24
|
lessThan(a: Address): boolean;
|
|
22
25
|
greaterThan(a: Address): boolean;
|
|
23
|
-
set(
|
|
26
|
+
set(mldsaPublicKey: ArrayLike<number>): void;
|
|
24
27
|
isValid(network: Network): boolean;
|
|
25
28
|
p2pk(): string;
|
|
26
29
|
p2wpkh(network: Network): string;
|