use of org.tron.core.exception.ValidateSignatureException in project java-tron by tronprotocol.
the class TransactionCapsule method validateSignature.
/**
* validate signature
*/
public boolean validateSignature() throws ValidateSignatureException {
if (this.getInstance().getSignatureCount() != this.getInstance().getRawData().getContractCount()) {
throw new ValidateSignatureException("miss sig or contract");
}
List<Transaction.Contract> listContract = this.transaction.getRawData().getContractList();
for (int i = 0; i < this.transaction.getSignatureCount(); ++i) {
try {
Transaction.Contract contract = listContract.get(i);
byte[] owner = getOwner(contract);
byte[] address = ECKey.signatureToAddress(getRawHash().getBytes(), getBase64FromByteString(this.transaction.getSignature(i)));
if (!Arrays.equals(owner, address)) {
throw new ValidateSignatureException("sig error");
}
} catch (SignatureException e) {
throw new ValidateSignatureException(e.getMessage());
}
}
return true;
}
Aggregations