Files
next.orly.dev/pkg/crypto/p8k/ecdh.go
mleku e0a95ca1cd
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
Refactor signer implementation to use p8k package
- Replaced all instances of p256k1signer with the new p8k.Signer across various modules, including event creation, policy handling, and database interactions.
- Updated related test cases and benchmarks to ensure compatibility with the new signer interface.
- Bumped version to v0.25.0 to reflect these significant changes and improvements in cryptographic operations.
2025-11-04 20:05:19 +00:00

33 lines
661 B
Go

package secp
import (
"fmt"
)
// ECDH computes an EC Diffie-Hellman shared secret
func (c *Context) ECDH(pubkey []byte, seckey []byte) (output []byte, err error) {
if ecdh == nil {
err = fmt.Errorf("ecdh module not available")
return
}
if len(pubkey) != PublicKeySize {
err = fmt.Errorf("public key must be %d bytes", PublicKeySize)
return
}
if len(seckey) != PrivateKeySize {
err = fmt.Errorf("private key must be %d bytes", PrivateKeySize)
return
}
output = make([]byte, SharedSecretSize)
ret := ecdh(c.ctx, &output[0], &pubkey[0], &seckey[0], 0, 0)
if ret != 1 {
err = fmt.Errorf("failed to compute ECDH")
return
}
return
}