Browse Source

Added

main
puma314 3 years ago
parent
commit
1f850e7ae1
3 changed files with 59 additions and 0 deletions
  1. +56
    -0
      ed25519.go
  2. +1
    -0
      go.mod
  3. +2
    -0
      go.sum

+ 56
- 0
ed25519.go

@ -0,0 +1,56 @@
// Copyright 2020 ConsenSys AG
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"fmt"
"os"
"crypto/ed25519"
"crypto/rand"
"github.com/consensys/gnark/std/math/emulated"
)
func main() {
err := mainImpl()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func mainImpl() error {
pubKey, privKey, err := ed25519.GenerateKey(rand.Reader)
fmt.Println(pubKey)
fmt.Println(privKey)
message := []byte("string")
sig := ed25519.Sign(privKey, message)
fmt.Println(sig)
verified := ed25519.Verify(pubKey, message, sig)
fmt.Println(verified)
verifiedFalse := ed25519.Verify(pubKey, []byte("string1"), sig)
fmt.Println(verifiedFalse)
ele := emulated.NewElement[emulated.BN254Fp](1)
fmt.Println(ele)
if err != nil {
return err
}
return nil
}

+ 1
- 0
go.mod

@ -14,6 +14,7 @@ require (
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/rs/zerolog v1.28.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75 // indirect
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

+ 2
- 0
go.sum

@ -34,6 +34,8 @@ github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75 h1:x03zeu7B2B11ySp+daztnwM5oBJ/8wGUSqrwcw9L0RA=
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

Loading…
Cancel
Save