@li0ard/gost - v0.2.3
    Preparing search index...

    Type Alias Signer

    GOST R 34.10 signer

    type Signer = {
        getPublicKey: (
            secretKey: TArg<Uint8Array>,
            isCompressed?: boolean,
        ) => TRet<Uint8Array>;
        getSharedSecret: (
            hash: CHash,
            secretKeyA: TArg<Uint8Array>,
            publicKeyB: TArg<Uint8Array>,
            ukm: TArg<Uint8Array>,
        ) => TRet<Uint8Array>;
        keygen: Keygen;
        Point: WeierstrassPointCons<bigint>;
        sign: (
            secretKey: TArg<Uint8Array>,
            digest: TArg<Uint8Array>,
            opts?: SignOpts,
        ) => TRet<Uint8Array>;
        utils: {
            parameters: GostCurveParameters;
            swapPoint: (point: TArg<Uint8Array>) => TRet<Uint8Array>;
            uv2xy: (point: AffinePoint<bigint>) => AffinePoint<bigint>;
            xy2uv: (point: AffinePoint<bigint>) => AffinePoint<bigint>;
        };
        verify: (
            publicKey: TArg<Uint8Array>,
            digest: TArg<Uint8Array>,
            signature: TArg<Uint8Array>,
        ) => boolean;
    }
    Index

    Properties

    getPublicKey: (
        secretKey: TArg<Uint8Array>,
        isCompressed?: boolean,
    ) => TRet<Uint8Array>

    Computes public key for a secret key. Checks for validity of the secret key.

    Type Declaration

      • (secretKey: TArg<Uint8Array>, isCompressed?: boolean): TRet<Uint8Array>
      • Parameters

        • secretKey: TArg<Uint8Array>
        • OptionalisCompressed: boolean

          whether to return compact (default), or full key

        Returns TRet<Uint8Array>

        Public key, full when isCompressed=false; short when isCompressed=true

    getSharedSecret: (
        hash: CHash,
        secretKeyA: TArg<Uint8Array>,
        publicKeyB: TArg<Uint8Array>,
        ukm: TArg<Uint8Array>,
    ) => TRet<Uint8Array>

    Key agreement function (ECDH)

    Computes hashed shared point from secret key A and public key B.

    Type Declaration

      • (
            hash: CHash,
            secretKeyA: TArg<Uint8Array>,
            publicKeyB: TArg<Uint8Array>,
            ukm: TArg<Uint8Array>,
        ): TRet<Uint8Array>
      • Parameters

        • hash: CHash

          Hash function to use (GOST R 34.11-94, Streebog-256, Streebog-512)

        • secretKeyA: TArg<Uint8Array>
        • publicKeyB: TArg<Uint8Array>
        • ukm: TArg<Uint8Array>

          User keying material (aka salt, VKO-factor)

        Returns TRet<Uint8Array>

    keygen: Keygen

    Keypair generator

    Point: WeierstrassPointCons<bigint>

    Constructor and metadata helpers for Weierstrass points

    sign: (
        secretKey: TArg<Uint8Array>,
        digest: TArg<Uint8Array>,
        opts?: SignOpts,
    ) => TRet<Uint8Array>

    Signs a message hash with a secret key.

    sign(d, m) where
    e = m mod n (if e=0, let e=1)
    k = streebog_hmac_drbg(d, m)
    (x, y) = G × k
    r = x mod n
    s = (rd + ke) mod n
    utils: {
        parameters: GostCurveParameters;
        swapPoint: (point: TArg<Uint8Array>) => TRet<Uint8Array>;
        uv2xy: (point: AffinePoint<bigint>) => AffinePoint<bigint>;
        xy2uv: (point: AffinePoint<bigint>) => AffinePoint<bigint>;
    }

    Utils

    Type Declaration

    • parameters: GostCurveParameters

      Curve parameters passed to gost3410 constructor

    • swapPoint: (point: TArg<Uint8Array>) => TRet<Uint8Array>

      Swap x and y in uncompressed point bytes (or r and s in signature)

    • uv2xy: (point: AffinePoint<bigint>) => AffinePoint<bigint>

      Convert point from Twisted Edwards to Weierstrass (if supported)

    • xy2uv: (point: AffinePoint<bigint>) => AffinePoint<bigint>

      Convert point from Weierstrass to Twisted Edwards (if supported)

    verify: (
        publicKey: TArg<Uint8Array>,
        digest: TArg<Uint8Array>,
        signature: TArg<Uint8Array>,
    ) => boolean

    Verifies a signature against message hash and public key.

    verify(P, m, r, s) where
    e = m mod n (if e=0, let e=1)
    v = e^-1 mod n
    z1 = sv mod n
    z2 = -rv mod n
    R = (z1 × G + z2 × P).x mod n
    R == r