mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-11-11 02:35:18 +00:00
28 lines
691 B
Go
28 lines
691 B
Go
//
|
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package frost
|
|
|
|
import (
|
|
"crypto/sha512"
|
|
|
|
"source.quilibrium.com/quilibrium/monorepo/nekryptology/pkg/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))
|
|
}
|