Example #1
0
func TestZero(t *testing.T) {
	for _, test := range ecTestCases {
		sk, _ := keyPairFromTestCase(test)

		if util.OrSlice(sk[:]) == 0 {
			t.Error("Secret key should not be all zeros before calling Zero")
			continue
		}

		sk.Zero()

		if util.OrSlice(sk[:]) != 0 {
			t.Error("Failed to zero secret key")
		}
	}
}
Example #2
0
func TestGenerateKeyPair(t *testing.T) {
	sk, pk, err := GenerateKeyPair()
	if err != nil {
		t.Error(err.Error())
		return
	}

	// Neither secret key or public key should be nil
	if sk == nil || pk == nil {
		t.Error("Failed to generate key pair")
		return
	}

	// Test that OR of secret key bytes is non-zero
	if util.OrSlice(sk[:]) == 0 {
		t.Error("Failed to initialize secret key")
		return
	}

	// Test that OR of public key bytes is non-zero
	if util.OrSlice(pk[:]) == 0 {
		t.Error("Failed to initialize public key")
	}
}
Example #3
0
// isZeroed returns a boolean value indicating whether or not the HDKey is
// empty.
func (k *HDKey) isZeroed() bool {
	return util.OrSlice(k[:]) == 0
}