Variable default

default: { checkAddress: ((address: string) => boolean); encryptSecretKey: ((key: string, passphrase: string, salt?: Uint8Array) => string); extractKeys: ((sk: string, passphrase?: string) => Promise<<internal>.Keys>); generateKeys: ((mnemonic: string, passphrase?: string, derivationPath?: string) => Promise<KeysMnemonicPassphrase>); generateMnemonic: ((numberOfWords??: number) => string); mnemonicToSeed: ((mnemonic: string, password?: string) => Promise<<internal>.Buffer>); sign: ((bytes: string, sk: string, magicBytes?: Uint8Array, password??: string) => Promise<Signed>); verify: ((bytes: string, sig: string, pk: string) => Promise<boolean>) }

Type declaration

  • checkAddress: ((address: string) => boolean)
      • (address: string): boolean
      • Description

        Check the validity of a tezos implicit address (tz1...)

        Returns

        Whether address is valid or not

        Parameters

        • address: string

          The address to check

        Returns boolean

  • encryptSecretKey: ((key: string, passphrase: string, salt?: Uint8Array) => string)
      • (key: string, passphrase: string, salt?: Uint8Array): string
      • Description

        Encrypts a secret key with a passphrase

        Returns

        The encrypted secret key

        Example

        const encryptedSecretKey = cryptoUtils.encryptSecretKey(
        'p2sk3T9fYpibobxRr7daoPzywLpLAXJVd3bkXpAaqYVtVB37aAp7bU',
        'password',
        );

        Parameters

        • key: string

          The secret key

        • passphrase: string

          The passphrase to encrypt the key

        • salt: Uint8Array = ...

          The salt to apply to the encryption

        Returns string

  • extractKeys: ((sk: string, passphrase?: string) => Promise<<internal>.Keys>)
      • (sk: string, passphrase?: string): Promise<<internal>.Keys>
      • Description

        Extract key pairs from a secret key

        Returns

        The extracted key pairs

        Example

        cryptoUtils.extractKeys('edskRqAF8s2MKKqRMxq53CYYLMnrqvokMyrtmPRFd5H9osc4bFmqKBY119jiiqKQMti2frLAoKGgZSQN3Lc3ybf5sgPUy38e5A')
        .then(({ sk, pk, pkh }) => console.log(sk, pk, pkh));

        Parameters

        • sk: string

          The secret key to extract key pairs from

        • Optional passphrase: string

          The password used to encrypt the sk

        Returns Promise<<internal>.Keys>

  • generateKeys: ((mnemonic: string, passphrase?: string, derivationPath?: string) => Promise<KeysMnemonicPassphrase>)
      • (mnemonic: string, passphrase?: string, derivationPath?: string): Promise<KeysMnemonicPassphrase>
      • Description

        Generate a new key pair given a mnemonic and passphrase

        Returns

        The generated key pair

        Example

        cryptoUtils.generateKeys('raw peace visual boil prefer rebel anchor right elegant side gossip enroll force salmon between', 'my_password_123')
        .then(({ mnemonic, passphrase, sk, pk, pkh }) => console.log(mnemonic, passphrase, sk, pk, pkh));

        // Or generate keys given an HD derivartion path
        cryptoUtils.generateKeys('gym exact clown can answer hope sample mirror knife twenty powder super imitate lion churn almost shed chalk dust civil gadget pyramid helmet trade', undefined, 'm/44h/1729h/0h/0h')
        .then(({ mnemonic, passphrase, sk, pk, pkh }) => console.log(mnemonic, passphrase, sk, pk, pkh));

        Parameters

        • mnemonic: string

          The mnemonic seed

        • Optional passphrase: string

          The passphrase used to salt the seed

        • Optional derivationPath: string

          Derivation path if generating keys for an HD account

        Returns Promise<KeysMnemonicPassphrase>

  • generateMnemonic: ((numberOfWords??: number) => string)
      • (numberOfWords??: number): string
      • Description

        Generate a mnemonic

        Returns

        The generated mnemonic

        Parameters

        • Optional numberOfWords: number = 15

          The number of words to include in the mnemonic

        Returns string

  • mnemonicToSeed: ((mnemonic: string, password?: string) => Promise<<internal>.Buffer>)
  • sign: ((bytes: string, sk: string, magicBytes?: Uint8Array, password??: string) => Promise<Signed>)
      • (bytes: string, sk: string, magicBytes?: Uint8Array, password??: string): Promise<Signed>
      • Description

        Sign bytes

        Returns

        The signed bytes

        Example

        import { magicBytes as magicBytesMap } from 'sotez';

        cryptoUtils.sign(opbytes, keys.sk, magicBytesMap.generic)
        .then(({ bytes, magicBytes, sig, prefixSig, sbytes }) => console.log(bytes, magicBytes, sig, prefixSig, sbytes));

        Parameters

        • bytes: string

          The bytes to sign

        • sk: string

          The secret key to sign the bytes with

        • Optional magicBytes: Uint8Array

          The magic bytes for the operation

        • Optional password: string = ''

          The password used to encrypt the sk

        Returns Promise<Signed>

  • verify: ((bytes: string, sig: string, pk: string) => Promise<boolean>)
      • (bytes: string, sig: string, pk: string): Promise<boolean>
      • Description

        Verify signed bytes

        Returns

        Whether the signed bytes are valid

        Parameters

        • bytes: string

          The signed bytes

        • sig: string

          The signature of the signed bytes

        • pk: string

          The public key

        Returns Promise<boolean>

Generated using TypeDoc