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