sonr/internal/crypto/ted25519/frost/challenge_derive.go
Prad Nukala 47c3a53080
refactor/internal (#1216)
* refactor: update import paths in gateway handlers

* refactor: remove obsolete devtools Makefile and README

* build: optimize build process for improved efficiency

* refactor: remove obsolete pkl files related to Matrix and Sonr network configurations

* refactor: move embed code to x/dwn/types
2024-12-24 16:10:20 +00:00

28 lines
671 B
Go
Executable File

//
// Copyright Coinbase, Inc. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
package frost
import (
"crypto/sha512"
"github.com/onsonr/sonr/internal/crypto/core/curves"
)
type ChallengeDerive interface {
DeriveChallenge(msg []byte, pubKey curves.Point, r curves.Point) (curves.Scalar, error)
}
type Ed25519ChallengeDeriver struct{}
func (ed Ed25519ChallengeDeriver) DeriveChallenge(msg []byte, pubKey curves.Point, r curves.Point) (curves.Scalar, error) {
h := sha512.New()
_, _ = h.Write(r.ToAffineCompressed())
_, _ = h.Write(pubKey.ToAffineCompressed())
_, _ = h.Write(msg)
return new(curves.ScalarEd25519).SetBytesWide(h.Sum(nil))
}