Signature

org.sigilaris.core.crypto.Signature
final case class Signature(v: Int, r: UInt256, s: UInt256)

ECDSA signature with recovery parameter for secp256k1.

Represents a recoverable ECDSA signature consisting of (v, r, s) where:

  • v is the recovery parameter (27-30) allowing public key recovery
  • r is the x-coordinate of the ephemeral public key
  • s is the signature proof value

Value parameters

r

signature component r, 32-byte datatype.UInt256

s

signature component s, 32-byte datatype.UInt256, normalized to Low-S form (s ≤ n/2)

v

recovery parameter, typically 27 or 28 (27 + recId where recId is 0 or 1)

Attributes

See also

Sign for signature creation

Recover for public key recovery

CryptoOps.sign for signing

CryptoOps.recover for recovery

Note

Signatures are normalized to Low-S form (s ≤ n/2) to prevent malleability

Example
 val keyPair   = CryptoOps.generate()
 val hash      = CryptoOps.keccak256("message".getBytes)
 val signature = CryptoOps.sign(keyPair, hash).toOption.get
 // Recover public key from signature
 val recovered = CryptoOps.recover(signature, hash)
Source
Signature.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Concrete fields

lazy override val toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Source
Signature.scala