github.com/ethersphere/bee/v2@v2.2.0/pkg/crypto/edg.go (about) 1 // Copyright 2023 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package crypto 6 7 import ( 8 "crypto/ecdsa" 9 ) 10 11 // edgSecp256_k1 aggregates private key cryptography functions that employ secp256k1 12 type edgSecp256_k1 struct{} 13 14 var EDGSecp256_K1 = new(edgSecp256_k1) 15 16 func (s *edgSecp256_k1) Generate() (*ecdsa.PrivateKey, error) { 17 return GenerateSecp256k1Key() 18 } 19 func (s *edgSecp256_k1) Encode(k *ecdsa.PrivateKey) ([]byte, error) { 20 return EncodeSecp256k1PrivateKey(k) 21 } 22 func (s *edgSecp256_k1) Decode(data []byte) (*ecdsa.PrivateKey, error) { 23 return DecodeSecp256k1PrivateKey(data) 24 } 25 26 // edgSecp256_r1 aggregates private key cryptography functions that employ secp256r1 27 type edgSecp256_r1 struct{} 28 29 var EDGSecp256_R1 = new(edgSecp256_r1) 30 31 func (s *edgSecp256_r1) Generate() (*ecdsa.PrivateKey, error) { 32 return GenerateSecp256r1Key() 33 } 34 func (s *edgSecp256_r1) Encode(k *ecdsa.PrivateKey) ([]byte, error) { 35 return EncodeSecp256r1PrivateKey(k) 36 } 37 func (s *edgSecp256_r1) Decode(data []byte) (*ecdsa.PrivateKey, error) { 38 return DecodeSecp256r1PrivateKey(data) 39 }