本文整理汇总了Golang中github.com/agl/ed25519.Sign函数的典型用法代码示例。如果您正苦于以下问题:Golang Sign函数的具体用法?Golang Sign怎么用?Golang Sign使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sign函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SignEnvelope
func (ch *Channel) SignEnvelope(ev wire.Envelope) (*wire.Envelope, error) {
// Put signature in correct slot
switch ch.Me {
case 1:
ev.Signature1 = ed25519.Sign(sliceTo64Byte(ch.Identity1.Privkey), ev.Payload)[:]
case 2:
ev.Signature2 = ed25519.Sign(sliceTo64Byte(ch.Identity2.Privkey), ev.Payload)[:]
}
return &ev, nil
}
开发者ID:jtremback,项目名称:upc-go,代码行数:11,代码来源:logic.go
示例2: updateSignatureProposer
func (ks *Keyserver) updateSignatureProposer() {
// invariant: do not access the db if ThisReplicaNeedsToSignLastEpoch = false
want := ks.rs.ThisReplicaNeedsToSignLastEpoch
have := ks.signatureProposer != nil
if have == want {
return
}
switch want {
case true:
tehBytes, err := ks.db.Get(tableEpochHeads(ks.rs.LastEpochDelimiter.EpochNumber))
if err != nil {
log.Panicf("ThisReplicaNeedsToSignLastEpoch but no TEH for last epoch in db: %s", err)
}
var teh proto.EncodedTimestampedEpochHead
if err := teh.Unmarshal(tehBytes); err != nil {
log.Panicf("tableEpochHeads(%d) invalid: %s", ks.rs.LastEpochDelimiter.EpochNumber, err)
}
seh := &proto.SignedEpochHead{
Head: teh,
Signatures: map[uint64][]byte{ks.replicaID: ed25519.Sign(ks.sehKey, tehBytes)[:]},
}
ks.signatureProposer = StartProposer(ks.log, ks.clk, ks.retryProposalInterval,
replication.LogEntry{Data: proto.MustMarshal(&proto.KeyserverStep{Type: &proto.KeyserverStep_ReplicaSigned{ReplicaSigned: seh}})})
case false:
ks.signatureProposer.Stop()
ks.signatureProposer = nil
}
}
开发者ID:maditya,项目名称:coname,代码行数:29,代码来源:server.go
示例3: Sign
// Sign signs the message with the private key using Ed25519.
func Sign(priv *PrivateKey, message []byte) ([]byte, bool) {
if !priv.Valid() {
return nil, false
}
sig := ed25519.Sign(priv.S, message)
return sig[:], true
}
开发者ID:kisom,项目名称:cryptutils,代码行数:8,代码来源:crypto.go
示例4: SetKeys
func (u *User) SetKeys(pubkey *[ed25519.PublicKeySize]byte, privkey *[ed25519.PrivateKeySize]byte) (err error) {
sign := ed25519.Sign(privkey, signtestmsg)
if ed25519.Verify(pubkey, signtestmsg, sign) {
return nil
}
return ErrInvalidKey
}
开发者ID:jackyyf,项目名称:isreversi,代码行数:7,代码来源:user.go
示例5: replyWithChallenge
func replyWithChallenge(w http.ResponseWriter, login string) {
var defaultSaltRaw [32]byte
rand.Read(defaultSaltRaw[:])
salt := base64.StdEncoding.EncodeToString(defaultSaltRaw[:])
u, ok := users[login]
if ok {
salt = u.Salt
}
var token [32]byte
rand.Read(token[:])
sig := ed25519.Sign(signingKey, token[:])
signedTokenRaw := make([]byte, len(token)+len(sig))
copy(signedTokenRaw, token[:])
copy(signedTokenRaw[len(token):], sig[:])
signedToken := base64.StdEncoding.EncodeToString(signedTokenRaw)
err := json.NewEncoder(w).Encode(challenge{signedToken, salt})
if err != nil {
log.Println(err)
http.Error(w, "Error with your request", http.StatusBadRequest)
}
}
开发者ID:rakoo,项目名称:challengeauth,代码行数:26,代码来源:main.go
示例6: Sign
// Sign returns a signature for a given blob
func (s *Ed25519Signer) Sign(request *pb.SignatureRequest) (*pb.Signature, error) {
priv := [ed25519.PrivateKeySize]byte{}
copy(priv[:], s.privateKey.Private())
sig := ed25519.Sign(&priv, request.Content)
return &pb.Signature{KeyInfo: &pb.KeyInfo{KeyID: &pb.KeyID{ID: s.privateKey.ID()}, Algorithm: &pb.Algorithm{Algorithm: data.ED25519Key.String()}}, Content: sig[:]}, nil
}
开发者ID:RichardScothern,项目名称:notary,代码行数:8,代码来源:ed25519_signer.go
示例7: Sign
func (ek *Ed25519PrivateKey) Sign(rand io.Reader, data []byte) (*ssh.Signature, error) {
signature := ed25519.Sign(ek.bytes, data)
return &ssh.Signature{
Format: ek.PublicKey().Type(),
Blob: (*signature)[:],
}, nil
}
开发者ID:fudanchii,项目名称:edssh,代码行数:7,代码来源:keys.go
示例8: Sign
func (p *RawPacket) Sign(privk *[ed25519.PrivateKeySize]byte) {
length := uint16(len(p.Payload))
buf := make([]byte, length+4)
binary.BigEndian.PutUint16(buf, length)
binary.BigEndian.PutUint16(buf[2:], p.Frametype)
copy(buf[4:], p.Payload)
p.Signature = ed25519.Sign(privk, buf)
}
开发者ID:jackyyf,项目名称:isreversi,代码行数:8,代码来源:packet.go
示例9: Factomize
// Create a factom.Entry and commit/reveal
func (a *APICall) Factomize() error {
type entryBody struct {
APIMethod string
ReturnData string
Timestamp int64
}
b := new(entryBody)
b.APIMethod = a.APIMethod
// get the ReturnData from the api call
resp, err := http.Get(a.APIMethod)
if err != nil {
return err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return fmt.Errorf(string(data))
}
b.ReturnData = string(data)
// get the current time
b.Timestamp = time.Now().Unix()
// create the factom entry
e := factom.NewEntry()
e.ChainID = a.ChainID
if e.Content, err = json.Marshal(b); err != nil {
return err
}
// Write the signature of the Entry Content to the first ExtID
e.ExtIDs = append(e.ExtIDs, func() []byte {
sec := new([64]byte)
if s, err := hex.DecodeString(a.SecKey); err != nil {
log.Fatal(err)
} else {
copy(sec[:], s)
}
return ed.Sign(sec, e.Content)[:]
}())
// Commit+Reveal the Entry to the Factom Network
if err := factom.CommitEntry(e, a.ECAddr); err != nil {
return err
}
time.Sleep(10 * time.Second)
if err := factom.RevealEntry(e); err != nil {
return err
}
return nil
}
开发者ID:FactomDemos,项目名称:apiwatch,代码行数:59,代码来源:apiwatch.go
示例10: SignKeys
func SignKeys(keys []*[32]byte, sk *[64]byte) [][]byte {
pkList := make([][]byte, 0)
for _, key := range keys {
signature := ed25519.Sign(sk, key[:])
pkList = append(pkList, append(append([]byte{}, key[:]...), signature[:]...))
}
return pkList
}
开发者ID:andres-erbsen,项目名称:chatterbox,代码行数:9,代码来源:client_util.go
示例11: CosignProposedUpdateTx
func (ch *Channel) CosignProposedUpdateTx() *wire.Envelope {
ev := ch.TheirProposedUpdateTxEnvelope
ev.Signatures[ch.Me] = ed25519.Sign(sliceTo64Byte(ch.Account.Privkey), ev.Payload)[:]
ch.LastFullUpdateTx = ch.TheirProposedUpdateTx
ch.LastFullUpdateTxEnvelope = ch.TheirProposedUpdateTxEnvelope
return ev
}
开发者ID:jtremback,项目名称:universal-state-channels,代码行数:9,代码来源:peer.go
示例12: Sign
// Sign a messageid.
func (keypair *SignKeyPair) Sign(msgID [MessageIDSize]byte) *[SignHeaderSize]byte {
signHeader := new([SignHeaderSize]byte)
signHeader[0] = byte(Version)
copy(signHeader[signHeaderPubkeyStart:signHeaderPubkeyEnd], keypair.PublicKey[:])
copy(signHeader[signHeaderNonceStart:signHeaderNonceEnd], keypair.Nonce[:])
signature := ed25519.Sign(keypair.PrivateKey, msgID[:])
copy(signHeader[signHeaderSignatureStart:signHeaderSignatureEnd], signature[:])
copy(signHeader[signHeaderMsgIDStart:signHeaderMsgIDEnd], msgID[:])
return signHeader
}
开发者ID:carriercomm,项目名称:repbin,代码行数:11,代码来源:sign.go
示例13: Sign
// Sign a SpendPacket.
func (s *SpendPacket) Sign(privkey *[ed25519.PrivateKeySize]byte) {
if privkey == nil {
s.Signature = []byte{0x00}
return
}
sig := ed25519.Sign(privkey, s.Image())
s.Signature = make([]byte, len(sig))
copy(s.Signature, sig[:])
return
}
开发者ID:JonathanLogan,项目名称:mute,代码行数:11,代码来源:types.go
示例14: ED25519Signature
// ED25519Signature returns the ED25519 signature of data using the key.
func ED25519Signature(key, data []byte) ([]byte, error) {
if len(key) != ed25519.PrivateKeySize {
return nil, fmt.Errorf("Invalid size of key (%v)", len(key))
}
var k [ed25519.PrivateKeySize]byte
copy(k[:], key)
signature := ed25519.Sign(&k, data)
return signature[:], nil
}
开发者ID:smitterson,项目名称:hc,代码行数:12,代码来源:ed25519.go
示例15: ed25519Sign
func ed25519Sign(privKey data.PrivateKey, message []byte) ([]byte, error) {
if privKey.Algorithm() != data.ED25519Key {
return nil, fmt.Errorf("private key type not supported: %s", privKey.Algorithm())
}
priv := [ed25519.PrivateKeySize]byte{}
copy(priv[:], privKey.Private()[ed25519.PublicKeySize:])
sig := ed25519.Sign(&priv, message)
return sig[:], nil
}
开发者ID:souravbh,项目名称:lattice-release,代码行数:11,代码来源:crypto_service.go
示例16: CounterSignToken
// CounterSignToken creates a counter-signature for token
// recPubKey is the public key of Bob. Returns true/false and the countersigned prooftoken
func CounterSignToken(proof *[ProofTokenSize]byte, recPubKey *[ed25519.PublicKeySize]byte, recPrivKey *[ed25519.PrivateKeySize]byte) (bool, *[ProofTokenSignedSize]byte) {
var counterSig [ProofTokenSignedSize]byte
ok, _, _ := VerifyProofToken(proof, recPubKey)
if !ok {
return false, nil
}
copy(counterSig[:ProofTokenSize], proof[:ProofTokenSize])
sig := ed25519.Sign(recPrivKey, proof[:ProofTokenSize])
copy(counterSig[ProofTokenSize:], sig[:ed25519.SignatureSize])
return true, &counterSig
}
开发者ID:carriercomm,项目名称:repbin,代码行数:13,代码来源:prooftoken.go
示例17: Sign
// Sign attempts to sign a a message with a provideded key.
func Sign(sk, message []byte) (signature []byte, err error) {
if len(message) == 0 {
return nil, errors.New("cannot sign an empty message")
}
key, err := ToByteArray64(sk)
if err != nil {
return nil, errors.New("invalid signing key")
}
signature = ed25519.Sign(key, message)[:]
return
}
开发者ID:pylls,项目名称:balloon,代码行数:13,代码来源:sign.go
示例18: signKEX
func signKEX(kex *[kexPubSize + SignatureSize]byte, signer *[IdentityPrivateSize]byte) bool {
if kex == nil {
return false
}
if signer == nil {
return true
}
sig := ed25519.Sign(signer, kex[:kexPubSize])
copy(kex[kexPubSize:], sig[:])
return true
}
开发者ID:jmptrader,项目名称:go-schannel,代码行数:13,代码来源:schannel.go
示例19: Unmarshal
// Unmarshal d into keypair.
func (keypair SignKeyPair) Unmarshal(d []byte) (*SignKeyPair, error) {
kp := new(SignKeyPair)
kp.PublicKey = new([SignerPubKeySize]byte)
kp.PrivateKey = new([ed25519.PrivateKeySize]byte)
copy(kp.PublicKey[:], d[0:SignerPubKeySize])
copy(kp.PrivateKey[:], d[SignerPubKeySize:SignerPubKeySize+ed25519.PrivateKeySize])
copy(kp.Nonce[:], d[SignerPubKeySize+ed25519.PrivateKeySize:SignerPubKeySize+ed25519.PrivateKeySize+hashcash.NonceSize])
kp.Bits = d[SignerPubKeySize+ed25519.PrivateKeySize+hashcash.NonceSize]
msg := []byte("validationtest")
if ed25519.Verify(kp.PublicKey, msg, ed25519.Sign(kp.PrivateKey, msg)) {
return kp, nil
}
return nil, ErrNoKeyFound
}
开发者ID:carriercomm,项目名称:repbin,代码行数:15,代码来源:sign.go
示例20: buildHMACDelivery
func (s *scriptState) buildHMACDelivery(to int, message []byte, seed int) *pond.Request {
pub, priv, digest := s.makeOneTimePubKey(to, seed)
sig := ed25519.Sign(priv, message)
return &pond.Request{
Deliver: &pond.Delivery{
To: s.publicIdentities[to][:],
Message: message,
OneTimePublicKey: pub[:],
HmacOfPublicKey: proto.Uint64(digest),
OneTimeSignature: sig[:],
},
}
}
开发者ID:carriercomm,项目名称:pond,代码行数:14,代码来源:server_test.go
注:本文中的github.com/agl/ed25519.Sign函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论