Refactor crypto package to use p256k1 signer
- Replaced the p256k package with p256k1.mleku.dev/signer across the codebase, updating all instances where the previous signer was utilized. - Removed the deprecated p256k package, including all related files and tests, to streamline the codebase and improve maintainability. - Updated various components, including event handling, database interactions, and protocol implementations, to ensure compatibility with the new signer interface. - Enhanced tests to validate the new signing functionality and ensure robustness across the application. - Bumped version to v0.23.3 to reflect these changes.
This commit is contained in:
@@ -3,7 +3,7 @@ package encryption
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"next.orly.dev/pkg/crypto/p256k"
|
||||
p256k1signer "p256k1.mleku.dev/signer"
|
||||
"lukechampine.com/frand"
|
||||
)
|
||||
|
||||
@@ -13,8 +13,8 @@ func createTestConversationKey() []byte {
|
||||
}
|
||||
|
||||
// createTestKeyPair creates a key pair for ECDH testing
|
||||
func createTestKeyPair() (*p256k.Signer, []byte) {
|
||||
signer := &p256k.Signer{}
|
||||
func createTestKeyPair() (*p256k1signer.P256K1Signer, []byte) {
|
||||
signer := p256k1signer.NewP256K1Signer()
|
||||
if err := signer.Generate(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -12,8 +12,9 @@ import (
|
||||
"golang.org/x/crypto/hkdf"
|
||||
"lol.mleku.dev/chk"
|
||||
"lol.mleku.dev/errorf"
|
||||
"next.orly.dev/pkg/crypto/p256k"
|
||||
p256k1signer "p256k1.mleku.dev/signer"
|
||||
"next.orly.dev/pkg/crypto/sha256"
|
||||
"next.orly.dev/pkg/encoders/hex"
|
||||
"next.orly.dev/pkg/interfaces/signer"
|
||||
"next.orly.dev/pkg/utils"
|
||||
)
|
||||
@@ -176,11 +177,16 @@ func GenerateConversationKeyFromHex(pkh, skh string) (ck []byte, err error) {
|
||||
return
|
||||
}
|
||||
var sign signer.I
|
||||
if sign, err = p256k.NewSecFromHex(skh); chk.E(err) {
|
||||
sign = p256k1signer.NewP256K1Signer()
|
||||
var sk []byte
|
||||
if sk, err = hex.Dec(skh); chk.E(err) {
|
||||
return
|
||||
}
|
||||
if err = sign.InitSec(sk); chk.E(err) {
|
||||
return
|
||||
}
|
||||
var pk []byte
|
||||
if pk, err = p256k.HexToBin(pkh); chk.E(err) {
|
||||
if pk, err = hex.Dec(pkh); chk.E(err) {
|
||||
return
|
||||
}
|
||||
var shared []byte
|
||||
|
||||
Reference in New Issue
Block a user