Skip to main content

ECDSA384

Overview​

License: MIT​

library ECDSA384

Cryptography module

This library provides functionality for ECDSA verification over any 384-bit curve. Currently, this is the most efficient implementation out there, consuming ~8.9 million gas per call.

The approach is Strauss-Shamir double scalar multiplication with 6 bits of precompute + affine coordinates.

Structs info​

Parameters​

struct Parameters {
bytes a;
bytes b;
bytes gx;
bytes gy;
bytes p;
bytes n;
}

384-bit curve parameters.

_Parameters​

struct _Parameters {
uint512 a;
uint512 b;
uint512 gx;
uint512 gy;
uint512 p;
uint512 n;
}

_Inputs​

struct _Inputs {
uint512 r;
uint512 s;
uint512 x;
uint512 y;
}

Functions info​

verify​

function verify(
ECDSA384.Parameters memory curveParams_,
bytes memory hashedMessage_,
bytes memory signature_,
bytes memory pubKey_
) internal view returns (bool)

The function to verify the ECDSA signature

Parameters:

NameTypeDescription
curveParams_struct ECDSA384.Parametersthe 384-bit curve parameters.
hashedMessage_bytesthe already hashed message to be verified.
signature_bytesthe ECDSA signature. Equals to bytes(r) + bytes(s).
pubKey_bytesthe full public key of a signer. Equals to bytes(x) + bytes(y). Note that signatures only from the lower part of the curve are accepted. If your s > n / 2, change it to s = n - s.