ethschnorr

package
v2.12.1-starknet-20240802 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ethschnorr implements a version of the Schnorr signature which is //////////////////////////////////////////////////////////////////////////////

XXX: Do not use in production until this code has been audited.

////////////////////////////////////////////////////////////////////////////// cheap to verify on-chain.

See https://en.wikipedia.org/wiki/Schnorr_signature For vanilla Schnorr.

Since we are targeting ethereum specifically, there is no need to abstract away the group operations, as original kyber Schnorr code does. Thus, these functions only work with secp256k1 objects, even though they are expressed in terms of the abstract kyber Group interfaces.

This code is largely based on EPFL-DEDIS's go.dedis.ch/kyber/sign/schnorr

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChallengeHash

func ChallengeHash(public kyber.Point, rAddress [20]byte, msg *big.Int) (
	kyber.Scalar, error)

ChallengeHash returns the value the signer must use to demonstrate knowledge of the secret key

NB: for parity with the on-chain hash, it's important that public and r marshall to the big-endian x ordinate, followed by a byte which is 0 if the y ordinate is even, 1 if it's odd. See evm/contracts/SchnorrSECP256K1.sol and evm/test/schnorr_test.js

func ValidSignature

func ValidSignature(s Signature) bool

ValidSignature(s) is true iff s.Signature represents an element of secp256k1

func Verify

func Verify(public kyber.Point, msg *big.Int, s Signature) error

Verify verifies the given Schnorr signature. It returns true iff the signature is valid.

Types

type Signature

type Signature = *signature

Signature is a representation of the Schnorr signature generated and verified by this library.

func NewSignature

func NewSignature() Signature

NewSignature allocates space for a Signature, and returns it

func Sign

func Sign(private kyber.Scalar, msg *big.Int) (Signature, error)

Sign creates a signature from a msg and a private key. Verify with the function Verify, or on-chain with SchnorrSECP256K1.sol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL