gnark-plonky2-verifier/ed25519.go
ed25519.goRaw
1// Copyright 2020 ConsenSys AG
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import (
18 "fmt"
19 "os"
20 "crypto/ed25519"
21 "crypto/rand"
22 "github.com/consensys/gnark/std/math/emulated"
23)
24
25
26
27func main() {
28 err := mainImpl()
29 if err != nil {
30 fmt.Println(err)
31 os.Exit(1)
32 }
33}
34
35func mainImpl() error {
36 pubKey, privKey, err := ed25519.GenerateKey(rand.Reader)
37 fmt.Println(pubKey)
38 fmt.Println(privKey)
39 message := []byte("string")
40 sig := ed25519.Sign(privKey, message)
41 fmt.Println(sig)
42 verified := ed25519.Verify(pubKey, message, sig)
43 fmt.Println(verified)
44
45 verifiedFalse := ed25519.Verify(pubKey, []byte("string1"), sig)
46 fmt.Println(verifiedFalse)
47
48 ele := emulated.NewElement[emulated.BN254Fp](1)
49 fmt.Println(ele)
50
51 if err != nil {
52 return err
53 }
54 return nil
55
56}