Ejemplo n.º 1
0
func freshSumRipemd160(b []byte) Ripemd160 {
	sh := ripemd160.New()
	sh.Write(b)
	h := Ripemd160{}
	h.Set(sh.Sum(nil))
	return h
}
Ejemplo n.º 2
0
func TestPubKeyToAddressHash(t *testing.T) {
	p, _ := GenerateKeyPair()
	h := p.ToAddressHash()
	// Should be Ripemd160(SHA256(SHA256()))
	x := sha256.Sum256(p[:])
	x = sha256.Sum256(x[:])
	rh := ripemd160.New()
	rh.Write(x[:])
	y := rh.Sum(nil)
	assert.True(t, bytes.Equal(h[:], y))
}
Ejemplo n.º 3
0
//do not allow program to start if crypto tests fail
func init() {
	// init the reuse hash pool.
	sha256HashChan = make(chan hash.Hash, poolsize)
	ripemd160HashChan = make(chan hash.Hash, poolsize)
	for i := 0; i < poolsize; i++ {
		sha256HashChan <- sha256.New()
		ripemd160HashChan <- ripemd160.New()
	}

	_, seckey := GenerateKeyPair()
	if TestSecKey(seckey) != nil {
		log.Fatal("CRYPTOGRAPHIC INTEGRITY CHECK FAILED: TERMINATING " +
			"PROGRAM TO PROTECT COINS")
	}
}
Ejemplo n.º 4
0
package secp256k1

import (
	//"crypto/sha256"
	//"encoding/hex"
	//"errors"
	"hash"
	//"log"

	"github.com/skycoin/skycoin/src/cipher/ripemd160"
)

var (
	//sha256Hash    hash.Hash = sha256.New()
	ripemd160Hash hash.Hash = ripemd160.New()
)

// Ripemd160

func _HashRipemd160(data []byte) []byte {
	ripemd160Hash.Reset()
	ripemd160Hash.Write(data)
	sum := ripemd160Hash.Sum(nil)
	return sum
}

// SHA256

// Double SHA256
func _DoubleSHA256(b []byte) []byte {
	//h := SumSHA256(b)