@multiversx/sdk-wallet
Advanced tools
Comparing version 4.0.0-beta.0 to 4.0.0-beta.1
export * from "./mnemonic"; | ||
export * from "./pem"; | ||
export * from "./userWallet"; | ||
export * from "./userKeys"; | ||
export * from "./validatorKeys"; | ||
export * from "./userSigner"; | ||
export * from "./guardianSigner"; | ||
export * from "./userVerifier"; | ||
export * from "./userWallet"; | ||
export * from "./validatorKeys"; | ||
export * from "./validatorSigner"; |
@@ -15,9 +15,8 @@ "use strict"; | ||
__exportStar(require("./pem"), exports); | ||
__exportStar(require("./userWallet"), exports); | ||
__exportStar(require("./userKeys"), exports); | ||
__exportStar(require("./validatorKeys"), exports); | ||
__exportStar(require("./userSigner"), exports); | ||
__exportStar(require("./guardianSigner"), exports); | ||
__exportStar(require("./userVerifier"), exports); | ||
__exportStar(require("./userWallet"), exports); | ||
__exportStar(require("./validatorKeys"), exports); | ||
__exportStar(require("./validatorSigner"), exports); | ||
//# sourceMappingURL=index.js.map |
/// <reference types="node" /> | ||
import { IAddress } from "./interface"; | ||
import { UserAddress } from "./userAddress"; | ||
export declare const USER_SEED_LENGTH = 32; | ||
@@ -18,6 +18,6 @@ export declare const USER_PUBKEY_LENGTH = 32; | ||
constructor(buffer: Buffer); | ||
verify(message: Buffer, signature: Buffer): boolean; | ||
verify(data: Buffer, signature: Buffer): boolean; | ||
hex(): string; | ||
toAddress(): IAddress; | ||
toAddress(): UserAddress; | ||
valueOf(): Buffer; | ||
} |
@@ -24,5 +24,5 @@ "use strict"; | ||
const tweetnacl = __importStar(require("tweetnacl")); | ||
const userAddress_1 = require("./userAddress"); | ||
const assertions_1 = require("./assertions"); | ||
const pem_1 = require("./pem"); | ||
const userAddress_1 = require("./userAddress"); | ||
exports.USER_SEED_LENGTH = 32; | ||
@@ -69,5 +69,5 @@ exports.USER_PUBKEY_LENGTH = 32; | ||
} | ||
verify(message, signature) { | ||
verify(data, signature) { | ||
try { | ||
const unopenedMessage = Buffer.concat([signature, message]); | ||
const unopenedMessage = Buffer.concat([signature, data]); | ||
const unsignedMessage = tweetnacl.sign.open(unopenedMessage, this.buffer); | ||
@@ -74,0 +74,0 @@ return unsignedMessage != null; |
@@ -1,2 +0,3 @@ | ||
import { IAddress, ISignable, ISigner } from "./interface"; | ||
/// <reference types="node" /> | ||
import { UserAddress } from "./userAddress"; | ||
import { UserSecretKey } from "./userKeys"; | ||
@@ -6,17 +7,12 @@ /** | ||
*/ | ||
export declare class UserSigner implements ISigner { | ||
export declare class UserSigner { | ||
protected readonly secretKey: UserSecretKey; | ||
constructor(secretKey: UserSecretKey); | ||
static fromWallet(keyFileObject: any, password: string): ISigner; | ||
static fromWallet(keyFileObject: any, password: string): UserSigner; | ||
static fromPem(text: string, index?: number): UserSigner; | ||
sign(data: Buffer): Promise<Buffer>; | ||
/** | ||
* Signs a message. | ||
* @param signable the message to be signed (e.g. a {@link Transaction}). | ||
*/ | ||
sign(signable: ISignable): Promise<void>; | ||
private trySign; | ||
/** | ||
* Gets the address of the signer. | ||
*/ | ||
getAddress(): IAddress; | ||
getAddress(): UserAddress; | ||
} |
@@ -13,6 +13,5 @@ "use strict"; | ||
exports.UserSigner = void 0; | ||
const signature_1 = require("./signature"); | ||
const errors_1 = require("./errors"); | ||
const userKeys_1 = require("./userKeys"); | ||
const userWallet_1 = require("./userWallet"); | ||
const errors_1 = require("./errors"); | ||
/** | ||
@@ -33,10 +32,7 @@ * ed25519 signer | ||
} | ||
/** | ||
* Signs a message. | ||
* @param signable the message to be signed (e.g. a {@link Transaction}). | ||
*/ | ||
sign(signable) { | ||
sign(data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
this.trySign(signable); | ||
const signature = this.secretKey.sign(data); | ||
return signature; | ||
} | ||
@@ -48,8 +44,2 @@ catch (err) { | ||
} | ||
trySign(signable) { | ||
let bufferToSign = signable.serializeForSigning(); | ||
let signatureBuffer = this.secretKey.sign(bufferToSign); | ||
let signature = new signature_1.Signature(signatureBuffer); | ||
signable.applySignature(signature); | ||
} | ||
/** | ||
@@ -56,0 +46,0 @@ * Gets the address of the signer. |
@@ -1,15 +0,21 @@ | ||
import { IAddress, IVerifiable, IVerifier } from "./interface"; | ||
/// <reference types="node" /> | ||
import { UserPublicKey } from "./userKeys"; | ||
interface IAddress { | ||
pubkey(): Buffer; | ||
} | ||
/** | ||
* ed25519 signature verification | ||
*/ | ||
export declare class UserVerifier implements IVerifier { | ||
export declare class UserVerifier { | ||
publicKey: UserPublicKey; | ||
constructor(publicKey: UserPublicKey); | ||
static fromAddress(address: IAddress): IVerifier; | ||
static fromAddress(address: IAddress): UserVerifier; | ||
/** | ||
* Verify a message's signature. | ||
* @param message the message to be verified. | ||
* | ||
* @param data the raw data to be verified (e.g. an already-serialized enveloped message) | ||
* @param signature the signature to be verified | ||
* @returns true if the signature is valid, false otherwise | ||
*/ | ||
verify(message: IVerifiable): boolean; | ||
verify(data: Buffer, signature: Buffer): boolean; | ||
} | ||
export {}; |
@@ -17,7 +17,9 @@ "use strict"; | ||
/** | ||
* Verify a message's signature. | ||
* @param message the message to be verified. | ||
* | ||
* @param data the raw data to be verified (e.g. an already-serialized enveloped message) | ||
* @param signature the signature to be verified | ||
* @returns true if the signature is valid, false otherwise | ||
*/ | ||
verify(message) { | ||
return this.publicKey.verify(message.serializeForSigning(this.publicKey.toAddress()), Buffer.from(message.getSignature().hex(), 'hex')); | ||
verify(data, signature) { | ||
return this.publicKey.verify(data, signature); | ||
} | ||
@@ -24,0 +26,0 @@ } |
{ | ||
"name": "@multiversx/sdk-wallet", | ||
"version": "4.0.0-beta.0", | ||
"version": "4.0.0-beta.1", | ||
"description": "Wallet components for MultiversX", | ||
@@ -5,0 +5,0 @@ "main": "out/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82088
72
1370