func (s *Shard) ValidateECDSA(proc *exec.Process, hashAddr int32, signatureAddr int32, pubkeyOut int32) int64 {
	var hash [32]byte
	s.SafeRead(proc, hashAddr, hash[:])

	var sigBytes [65]byte
	s.SafeRead(proc, signatureAddr, sigBytes[:])

	// as long as hash is a random oracle (not chosen by the user),
	// we can derive the pubkey from the signature and the hash.
	pub, _, err := secp256k1.RecoverCompact(sigBytes[:], hash[:])
	if err != nil {
		return 1
	}

	var pubkeyCompressed [33]byte

	copy(pubkeyCompressed[:], pub.Serialize())

	s.SafeWrite(proc, pubkeyOut, pubkeyCompressed[:])

	sig := DecompressSignature(sigBytes)

	if !sig.Verify(hash[:], pub) {
		return 2
	}
	return 0
}
// ValidateECDSA validates a certain ECDSA signature.
ValidateECDSA validates a certain ECDSA signature.
// ValidateECDSA validates a certain ECDSA signature .
func (s *Shard) ValidateECDSA(proc *exec.Process, hashAddr int32, signatureAddr int32, pubkeyOut int32) int64 {
	var hash [32]byte
	s.SafeRead(proc, hashAddr, hash[:])
	var sigBytes [65]byte
	s.SafeRead(proc, signatureAddr, sigBytes[:])
	pub, _, err := secp256k1.RecoverCompact(sigBytes[:], hash[:])
	if err != nil {
		return 1
	}
	var pubkeyCompressed [33]byte
	copy(pubkeyCompressed[:], pub.Serialize())
	s.SafeWrite(proc, pubkeyOut, pubkeyCompressed[:])
	sig := DecompressSignature(sigBytes)
	if !sig.Verify(hash[:], pub) {
		return 2
	}
	return 0
}
func ( s * Shard ) ValidateECDSA ( proc * exec . Process , hashAddr int32 , signatureAddr int32 , pubkeyOut int32 ) int64 { var hash [ 32 ] byte s . SafeRead ( proc , hashAddr , hash [ : ] ) var sigBytes [ 65 ] byte s . SafeRead ( proc , signatureAddr , sigBytes [ : ] ) pub , _ , err := secp256k1 . RecoverCompact ( sigBytes [ : ] , hash [ : ] ) if err != nil { return 1 } var pubkeyCompressed [ 33 ] byte copy ( pubkeyCompressed [ : ] , pub . Serialize ( ) ) s . SafeWrite ( proc , pubkeyOut , pubkeyCompressed [ : ] ) sig := DecompressSignature ( sigBytes ) if ! sig . Verify ( hash [ : ] , pub ) { return 2 } return 0 }
ValidateECDSA validates a certain ECDSA signature.
ValidateECDSA validates a certain ECDSA signature .
// as long as hash is a random oracle (not chosen by the user), // we can derive the pubkey from the signature and the hash.