本文整理汇总了Golang中github.com/dedis/crypto/abstract.Point类的典型用法代码示例。如果您正苦于以下问题:Golang Point类的具体用法?Golang Point怎么用?Golang Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Point类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: newSession
func (rh *RandHound) newSession(public abstract.Point, purpose string, time time.Time) (*Session, []byte, error) {
buf := new(bytes.Buffer)
pub, err := public.MarshalBinary()
if err != nil {
return nil, nil, err
}
if err = binary.Write(buf, binary.LittleEndian, pub); err != nil {
return nil, nil, err
}
tm, err := time.MarshalBinary()
if err != nil {
return nil, nil, err
}
if err = binary.Write(buf, binary.LittleEndian, tm); err != nil {
return nil, nil, err
}
if err = binary.Write(buf, binary.LittleEndian, []byte(purpose)); err != nil {
return nil, nil, err
}
return &Session{
Fingerprint: pub,
Purpose: purpose,
Time: time}, rh.hash(buf.Bytes()), nil
}
开发者ID:nikirill,项目名称:cothority,代码行数:27,代码来源:randhound.go
示例2: ownerEncode
func (c *ownedCoder) ownerEncode(payload, payout []byte, p abstract.Point) {
// XXX trap-encode
// Pick a fresh random key with which to encrypt the payload
key := make([]byte, c.keylen)
c.random.XORKeyStream(key, key)
// Encrypt the payload with it
c.suite.Cipher(key).XORKeyStream(payout, payload)
// Compute a MAC over the encrypted payload
h := c.suite.Hash()
h.Write(payout)
mac := h.Sum(nil)[:c.maclen]
// Combine the key and the MAC into the Point for this cell header
hdr := append(key, mac...)
if len(hdr) != p.PickLen() {
panic("oops, length of key+mac turned out wrong")
}
mp, _ := c.suite.Point().Pick(hdr, c.random)
// Add this to the blinding point we already computed to transmit.
p.Add(p, mp)
}
开发者ID:ineiti,项目名称:prifi,代码行数:26,代码来源:owned.go
示例3: HashKDF
// HashKDF is a random map from G to Z_p, for use as the key derivation function (KDF) in the hash-based Verdict
// construction
func HashKDF(point abstract.Point) abstract.Secret {
bytes, _ := point.MarshalBinary()
cipher := Suite.Cipher(bytes)
// This seems to be the only easy way to get outside data reliably in an abstract.Secret.
return Suite.Secret().Pick(cipher)
}
开发者ID:confiks,项目名称:ipfs-dc,代码行数:9,代码来源:crypto.go
示例4: Verify
// Verify takes a signature issued by EdDSA.Sign and
// return nil if it is a valid signature, or an error otherwise
// Takes:
// - public key used in signing
// - msg is the message to sign
// - sig is the signature return by EdDSA.Sign
func Verify(public abstract.Point, msg, sig []byte) error {
if len(sig) != 64 {
return errors.New("Signature length invalid")
}
R := suite.Point()
if err := R.UnmarshalBinary(sig[:32]); err != nil {
return fmt.Errorf("R invalid point: %s", err)
}
s := suite.Scalar()
s.UnmarshalBinary(sig[32:])
// reconstruct h = H(R || Public || Msg)
Pbuff, err := public.MarshalBinary()
if err != nil {
return err
}
hash := sha512.New()
hash.Write(sig[:32])
hash.Write(Pbuff)
hash.Write(msg)
h := suite.Scalar().SetBytes(hash.Sum(nil))
// reconstruct S == k*A + R
S := suite.Point().Mul(nil, s)
hA := suite.Point().Mul(public, h)
RhA := suite.Point().Add(R, hA)
if !RhA.Equal(S) {
return errors.New("Recontructed S is not equal to signature")
}
return nil
}
开发者ID:LegoShrimp,项目名称:crypto,代码行数:40,代码来源:eddsa.go
示例5: VerifySignature
// Verifies that the 'message' is included in the signature and that it
// is correct.
// Message is your own hash, and reply contains the inclusion proof + signature
// on the aggregated message
func VerifySignature(suite abstract.Suite, reply *StampSignature, public abstract.Point, message []byte) bool {
// Check if aggregate public key is correct
if !public.Equal(reply.AggPublic) {
dbg.Lvl1("Aggregate-public-key check: FAILED (maybe you have an outdated config file of the tree)")
return false
}
// First check if the challenge is ok
if err := VerifyChallenge(suite, reply); err != nil {
dbg.Lvl1("Challenge-check: FAILED (", err, ")")
return false
}
dbg.Lvl2("Challenge-check: OK")
// Incorporate the timestamp in the message since the verification process
// is done by reconstructing the challenge
var b bytes.Buffer
if err := binary.Write(&b, binary.LittleEndian, reply.Timestamp); err != nil {
dbg.Lvl1("Error marshaling the timestamp for signature verification")
return false
}
msg := append(b.Bytes(), []byte(reply.MerkleRoot)...)
if err := VerifySchnorr(suite, msg, public, reply.Challenge, reply.Response); err != nil {
dbg.Lvl1("Signature-check: FAILED (", err, ")")
return false
}
dbg.Lvl2("Signature-check: OK")
// finally check the proof
if !proof.CheckProof(suite.Hash, reply.MerkleRoot, hashid.HashId(message), reply.Prf) {
dbg.Lvl2("Inclusion-check: FAILED")
return false
}
dbg.Lvl2("Inclusion-check: OK")
return true
}
开发者ID:mlncn,项目名称:cothority,代码行数:39,代码来源:verification.go
示例6: SchnorrVerify
// Checks the signature against
// the message
func SchnorrVerify(suite abstract.Suite,
kp SchnorrPublicKey,
msg []byte, sig []byte) (bool, error) {
buf := bytes.NewBuffer(sig)
signature := SchnorrSignature{}
err := abstract.Read(buf, &signature, suite)
if err != nil {
return false, err
}
s := signature.S
e := signature.E
var gs, ye, r abstract.Point
gs = suite.Point().Mul(nil, s) // g^s
ye = suite.Point().Mul(kp.Y, e) // y^e
r = suite.Point().Add(gs, ye) // g^xy^e
r_bin, _ := r.MarshalBinary()
msg_and_r := append(msg, r_bin...)
hasher := sha3.New256()
hasher.Write(msg_and_r)
h := hasher.Sum(nil)
// again I'm hoping this just reads the state out
// and doesn't actually perform any ops
lct := suite.Cipher(h)
ev := suite.Secret().Pick(lct)
return ev.Equal(e), nil
}
开发者ID:diagprov,项目名称:interview-go-multisigs,代码行数:34,代码来源:schnorr.go
示例7: PointMarshalTo
// PointEncodeTo provides a generic implementation of Point.EncodeTo
// based on Point.Encode.
func PointMarshalTo(p abstract.Point, w io.Writer) (int, error) {
buf, err := p.MarshalBinary()
if err != nil {
return 0, err
}
return w.Write(buf)
}
开发者ID:LegoShrimp,项目名称:crypto,代码行数:9,代码来源:encoding.go
示例8: MarshalPoint
func MarshalPoint(pt abstract.Point) []byte {
buf := new(bytes.Buffer)
ptByte := make([]byte, SecretSize)
pt.MarshalTo(buf)
buf.Read(ptByte)
return ptByte
}
开发者ID:Xyroe,项目名称:riffle,代码行数:7,代码来源:utils.go
示例9: diffieHellmanSecret
/* Given a Diffie-Hellman shared public key, produces a secret to encrypt
* another secret
*
* Arguments
* diffieBase = the DH shared public key
*
* Return
* the DH secret
*/
func (p *Deal) diffieHellmanSecret(diffieBase abstract.Point) abstract.Secret {
buff, err := diffieBase.MarshalBinary()
if err != nil {
panic("Bad shared secret for Diffie-Hellman given.")
}
cipher := p.suite.Cipher(buff)
return p.suite.Secret().Pick(cipher)
}
开发者ID:eftychis,项目名称:crypto-1,代码行数:17,代码来源:deal.go
示例10: verifyCertificate
/* Verifies that a PolicyApproveMessage has been properly constructed.
*
* Arguments:
* su = the suite that the insurer's public key was derived from.
* insuredKey = the public key of the insured or the client
* insurerKey = the public key of the insurer or "trustee"
*
* Returns:
* whether or not the message is valid.
*/
func (msg *PolicyApprovedMessage) verifyCertificate(su abstract.Suite,
insuredKey abstract.Point) bool {
set := anon.Set{msg.PubKey}
_, err := anon.Verify(su, msg.Message, set, nil, msg.Signature)
correctMsg := msg.PubKey.String() + " insures " + insuredKey.String()
return err == nil && correctMsg == string(msg.Message)
}
开发者ID:ineiti,项目名称:prifi,代码行数:18,代码来源:policyMessage.go
示例11: NewServerIdentity
// NewServerIdentity creates a new ServerIdentity based on a public key and with a slice
// of IP-addresses where to find that entity. The Id is based on a
// version5-UUID which can include a URL that is based on it's public key.
func NewServerIdentity(public abstract.Point, addresses ...string) *ServerIdentity {
url := NamespaceURL + "id/" + public.String()
return &ServerIdentity{
Public: public,
Addresses: addresses,
ID: ServerIdentityID(uuid.NewV5(uuid.NamespaceURL, url)),
}
}
开发者ID:nikirill,项目名称:cothority,代码行数:11,代码来源:struct.go
示例12: sub
// accommodate nils
func (sn *Node) sub(a abstract.Point, b abstract.Point) {
if a == nil {
a = sn.suite.Point().Null()
}
if b != nil {
a.Sub(a, b)
}
}
开发者ID:mlncn,项目名称:cothority,代码行数:9,代码来源:nodeutils.go
示例13: hashMessage
// Returns a hash of the message and the random secret:
// H( m || V )
// Returns an error if something went wrong with the marshalling
func (s *Schnorr) hashMessage(msg []byte, v abstract.Point) (abstract.Scalar, error) {
vb, err := v.MarshalBinary()
if err != nil {
return nil, err
}
c := s.suite.Cipher(vb)
c.Message(nil, nil, msg)
return s.suite.Scalar().Pick(c), nil
}
开发者ID:LegoShrimp,项目名称:crypto,代码行数:12,代码来源:schnorr.go
示例14: AddConn
/* Adds a new connection to the connection manager
*
* Arguments:
* theirkey = the key of the peer that this server wishes to connect to
*
* Returns:
* An error denoting whether creating the new connection was successful.
*/
func (gcm *ChanConnManager) AddConn(theirKey abstract.Point) error {
newConn, err := coconet.NewGoConn(gcm.dir, gcm.pubKey.String(),
theirKey.String())
if err != nil {
return err
}
gcm.peerMap[theirKey.String()] = newConn
return nil
}
开发者ID:ineiti,项目名称:prifi,代码行数:17,代码来源:chanConnManager.go
示例15: signH1pre
func signH1pre(suite abstract.Suite, linkScope []byte, linkTag abstract.Point,
message []byte) abstract.Cipher {
H1pre := suite.Cipher(message) // m
if linkScope != nil {
H1pre.Write(linkScope) // L
tag, _ := linkTag.MarshalBinary()
H1pre.Write(tag) // ~y
}
return H1pre
}
开发者ID:eftychis,项目名称:crypto-1,代码行数:10,代码来源:sig.go
示例16: AddClient
func (c *Coordinator) AddClient(key abstract.Point, val *net.UDPAddr) {
// delete the client who has same ip address
for k, v := range c.Clients {
if v.String() == val.String() {
delete(c.Clients, k)
break
}
}
c.Clients[key.String()] = val
}
开发者ID:anonyreputation,项目名称:anonCred,代码行数:10,代码来源:Coordinator.go
示例17: SchnorrMComputeSharedPublicKey
// (Either side) This function computes the shared public key
// by adding public key points over the curve group.
// Since each public key is already g*k where g is the group
// generator this is all we need to do
func SchnorrMComputeSharedPublicKey(suite abstract.Suite,
pkeys []SchnorrPublicKey) SchnorrMultiSignaturePublicKey {
var P abstract.Point = pkeys[0].Y
for _, pkey := range pkeys[1:] {
P.Add(P, pkey.Y)
}
return SchnorrMultiSignaturePublicKey{P}
}
开发者ID:diagprov,项目名称:interview-go-multisigs,代码行数:14,代码来源:multisignatures.go
示例18: createMessage
/* Creates a new policy-approved message
*
* Arguments:
* kp = the private/public key of the insuring server.
* theirKey = the public key of the server who requested the insurance
*
* Returns:
* A new policy approved message.
*
* NOTE:
* The approved certificate is a string of the form:
* "My_Public_Key insures Their_Public_Key"
*
* It will always be of this form for easy validation.
*/
func (msg *PolicyApprovedMessage) createMessage(kp *config.KeyPair,
theirKey abstract.Point) *PolicyApprovedMessage {
set := anon.Set{kp.Public}
approveMsg := kp.Public.String() + " insures " + theirKey.String()
msg.PubKey = kp.Public
msg.Message = []byte(approveMsg)
msg.Signature = anon.Sign(kp.Suite, random.Stream, msg.Message,
set, nil, 0, kp.Secret)
return msg
}
开发者ID:ineiti,项目名称:prifi,代码行数:26,代码来源:policyMessage.go
示例19: signH1
func signH1(suite abstract.Suite, H1pre abstract.Cipher, PG, PH abstract.Point) abstract.Secret {
H1 := H1pre.Clone()
PGb, _ := PG.MarshalBinary()
H1.Write(PGb)
if PH != nil {
PHb, _ := PH.MarshalBinary()
H1.Write(PHb)
}
H1.Message(nil, nil, nil) // finish message absorption
return suite.Secret().Pick(H1)
}
开发者ID:eftychis,项目名称:crypto-1,代码行数:11,代码来源:sig.go
示例20: hash
func hash(suite abstract.Suite, r abstract.Point, msg []byte) (abstract.Scalar, error) {
rBuf, err := r.MarshalBinary()
if err != nil {
return nil, err
}
cipher := suite.Cipher(rBuf)
cipher.Message(nil, nil, msg)
// (re)compute challenge (e)
e := suite.Scalar().Pick(cipher)
return e, nil
}
开发者ID:nikirill,项目名称:cothority,代码行数:12,代码来源:schnorr.go
注:本文中的github.com/dedis/crypto/abstract.Point类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论