CryptoOpsLike

org.sigilaris.core.crypto.CryptoOpsLike

Cross-platform minimal CryptoOps surface to unify JS/JVM APIs.

Provides cryptographic primitives for secp256k1 elliptic curve operations including hashing, key pair generation, signing, and signature recovery. Platform-specific implementations exist for JS (via elliptic.js) and JVM (via BouncyCastle).

Attributes

See also

org.sigilaris.core.crypto.CryptoOps for platform-specific implementations

Source
CryptoOpsLike.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object CryptoOps

Members list

Value members

Abstract methods

def fromPrivate(privateKey: BigInt): KeyPair

Derives a key pair from an existing private key.

Derives a key pair from an existing private key.

The caller is expected to supply a value in the valid range [1, n-1] where n is the curve order. The implementation reduces privateKey mod n before scalar multiplication and only validates that the value fits into a UInt256; it does not reject out-of-range inputs explicitly.

Value parameters

privateKey

private key as BigInt; should be in range [1, n-1] (prevalidated)

Attributes

Returns

KeyPair with the given private key and derived public key

Throws
Exception

if privateKey cannot be represented as a UInt256

Source
CryptoOpsLike.scala
def generate(): KeyPair

Generates a new random secp256k1 key pair.

Generates a new random secp256k1 key pair.

Attributes

Returns

fresh KeyPair with random private key

Note

Uses cryptographically secure random source (SecureRandom on JVM, crypto.getRandomValues on JS)

Source
CryptoOpsLike.scala
def keccak256(input: Array[Byte]): Array[Byte]

Computes Keccak-256 hash of input bytes.

Computes Keccak-256 hash of input bytes.

Value parameters

input

message bytes to hash

Attributes

Returns

32-byte hash digest

Note

Thread-safe on JVM (uses thread-local pool); safe on JS (single- threaded)

Source
CryptoOpsLike.scala
def recover(signature: Signature, hashArray: Array[Byte]): Either[SigilarisFailure, PublicKey]

Recovers public key from signature and message hash.

Recovers public key from signature and message hash.

Value parameters

hashArray

32-byte message hash that was signed

signature

ECDSA signature with recovery parameter

Attributes

Returns

Right(PublicKey) on success, Left(failure) if recovery fails

Note
  • Accepts both High-S and Low-S signatures
  • Recovery parameter (v) must be 27, 28, 29, or 30
Source
CryptoOpsLike.scala
def sign(keyPair: KeyPair, transactionHash: Array[Byte]): Either[SigilarisFailure, Signature]

Signs a message hash with ECDSA.

Signs a message hash with ECDSA.

Value parameters

keyPair

key pair to sign with

transactionHash

32-byte message hash to sign

Attributes

Returns

Right(Signature) on success, Left(failure) if signing fails

Note
  • Uses deterministic k-generation (RFC 6979)
  • Normalizes signatures to Low-S form
  • Includes recovery parameter (v = 27 + recId)
  • Rejects hashes whose length is not exactly 32 bytes before signing
Source
CryptoOpsLike.scala