1 Star 0 Fork 0

jkuang/fast ecdsa

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
example_test.go 656 Bytes
一键复制 编辑 原始数据 按行查看 历史
jkuang 提交于 5年前 . initital work
// Copyright 2018 The Go 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 fastecdsa
import (
"crypto/elliptic"
"crypto/rand"
"crypto/sha256"
"fmt"
)
func Example() {
privateKey, err := GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
panic(err)
}
msg := "hello, world"
hash := sha256.Sum256([]byte(msg))
r, s, err := Sign(rand.Reader, privateKey, hash[:])
if err != nil {
panic(err)
}
fmt.Printf("signature: (0x%x, 0x%x)\n", r, s)
valid := Verify(&privateKey.PublicKey, hash[:], r, s)
fmt.Println("signature verified:", valid)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jkuang/go-fastecdsa.git
git@gitee.com:jkuang/go-fastecdsa.git
jkuang
go-fastecdsa
fast ecdsa
master

搜索帮助