// Sign generates a lamport signature over hashed.
//
// Will panic if hash function not linked to binary.
// It is expected that "hashed" was generated by priv.Hash,
// but it's only necessary that it be the same length as the
// hash size.
Sign generates a lamport signature over hashed.

Will panic if hash function not linked to binary.
It is expected that "hashed" was generated by priv.Hash,
but it's only necessary that it be the same length as the
hash size.
// Sign generates a lamport signature over hashed . // // Will panic if hash function not linked to binary . // It is expected that " hashed " was generated by priv . Hash // but it ' s only necessary that it be the same length as the // hash size .
func Sign(priv *PrivateKey, hashed []byte) ([]byte, error) {
	hash := priv.Hash.New()
	hashSize := hash.Size()
	if hashSize != len(hashed) {
		return nil, fmt.Errorf("lamport: hash length mismatch")
	}
	sigSize := 8 * hashSize * hashSize
	sig := make([]byte, 0, sigSize)
	off := 0
	for _, b := range hashed {
		for _, o := range ones {
			if b&o == 0 {
				sig = append(sig, priv.LBlocks[off:off+hashSize]...)
			} else {
				sig = append(sig, priv.RBlocks[off:off+hashSize]...)
			}
			off += hashSize
		}
	}
	return sig, nil
}
func Sign ( priv * PrivateKey , hashed [ ] byte ) ( [ ] byte , error ) { hash := priv . Hash . New ( ) hashSize := hash . Size ( ) if hashSize != len ( hashed ) { return nil , fmt . Errorf ( " " ) } sigSize := 8 * hashSize * hashSize sig := make ( [ ] byte , 0 , sigSize ) off := 0 for _ , b := range hashed { for _ , o := range ones { if b & o == 0 { sig = append ( sig , priv . LBlocks [ off : off + hashSize ] ... ) } else { sig = append ( sig , priv . RBlocks [ off : off + hashSize ] ... ) } off += hashSize } } return sig , nil }
Sign generates a lamport signature over hashed.
Sign generates a lamport signature over hashed .
// panic immediately if hash not linked