How to use the @ethersproject/signing-key.SigningKey.isSigningKey function in @ethersproject/signing-key

To help you get started, we’ve selected a few @ethersproject/signing-key examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ethers-io / ethers.js / packages / wallet / lib.esm / index.js View on Github external
const mnemonic = privateKey.mnemonic;
                const path = privateKey.path || defaultPath;
                defineReadOnly(this, "_mnemonic", () => mnemonic);
                defineReadOnly(this, "path", privateKey.path);
                const node = HDNode.fromMnemonic(mnemonic).derivePath(path);
                if (computeAddress(node.privateKey) !== this.address) {
                    logger.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]");
                }
            }
            else {
                defineReadOnly(this, "_mnemonic", () => null);
                defineReadOnly(this, "path", null);
            }
        }
        else {
            if (SigningKey.isSigningKey(privateKey)) {
                if (privateKey.curve !== "secp256k1") {
                    logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]");
                }
                defineReadOnly(this, "_signingKey", () => privateKey);
            }
            else {
                const signingKey = new SigningKey(privateKey);
                defineReadOnly(this, "_signingKey", () => signingKey);
            }
            defineReadOnly(this, "_mnemonic", () => null);
            defineReadOnly(this, "path", null);
            defineReadOnly(this, "address", computeAddress(this.publicKey));
        }
        if (provider && !Provider.isProvider(provider)) {
            logger.throwArgumentError("invalid provider", "provider", provider);
        }
github ethers-io / ethers.js / packages / wallet / src.ts / index.ts View on Github external
const mnemonic = privateKey.mnemonic;
                const path = privateKey.path || defaultPath;
                defineReadOnly(this, "_mnemonic", () => mnemonic);
                defineReadOnly(this, "path", privateKey.path);
                const node = HDNode.fromMnemonic(mnemonic).derivePath(path);
                if (computeAddress(node.privateKey) !== this.address) {
                    logger.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]");
                }
            } else {
                defineReadOnly(this, "_mnemonic", (): string => null);
                defineReadOnly(this, "path", null);
            }


        } else {
            if (SigningKey.isSigningKey(privateKey)) {
                if (privateKey.curve !== "secp256k1") {
                    logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]");
                }
                defineReadOnly(this, "_signingKey", () => privateKey);
            } else {
                const signingKey = new SigningKey(privateKey);
                defineReadOnly(this, "_signingKey", () => signingKey);
            }
            defineReadOnly(this, "_mnemonic", (): string => null);
            defineReadOnly(this, "path", null);
            defineReadOnly(this, "address", computeAddress(this.publicKey));
        }

        if (provider && !Provider.isProvider(provider)) {
            logger.throwArgumentError("invalid provider", "provider", provider);
        }

@ethersproject/signing-key

Elliptic curve library functions for the secp256k1 curve.

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis