multi: handle all blinding point validation in ValidateParsedPayloadTypes
This commit moves all our validation related to the presence of fields into ValidateParsedPayloadTypes so that we can handle them in a single place. We draw the distinction between: - Validation of the payload (and the context within it's being parsed, final hop / blinded hop etc) - Processing and validation of encrypted data, where we perform additional cryptographic operations and validate that the fields contained in the blob are valid. This helps draw the line more clearly between the two validation types, rather than splitting some payload-releated blinded hop processing into the encrypted data processing part. The downside of this approach (vs doing the blinded path payload check _after_ payload validation) is that we have to pass additional context into payload validation (ie, whether we got a blinding point in our UpdateAddHtlc - as we already do for isFinalHop).
This commit is contained in:
5 files changed
+174
-75
No files matched your search
@@ -216,24 +216,10 @@ func TestDecryptAndValidateFwdInfo(t *testing.T) {
|
||||
expectedErr error
|
||||
}{
|
||||
{
|
||||
name: "no blinding point",
|
||||
data: validData,
|
||||
processor: &mockProcessor{},
|
||||
expectedErr: ErrInvalidPayload{
|
||||
Type: record.BlindingPointOnionType,
|
||||
Violation: OmittedViolation,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "both blinding points",
|
||||
data: validData,
|
||||
updateAddBlinding: &btcec.PublicKey{},
|
||||
payloadBlinding: &btcec.PublicKey{},
|
||||
processor: &mockProcessor{},
|
||||
expectedErr: ErrInvalidPayload{
|
||||
Type: record.BlindingPointOnionType,
|
||||
Violation: IncludedViolation,
|
||||
},
|
||||
name: "no blinding point",
|
||||
data: validData,
|
||||
processor: &mockProcessor{},
|
||||
expectedErr: ErrNoBlindingPoint,
|
||||
},
|
||||
{
|
||||
name: "decryption failed",
|
||||
@@ -265,12 +251,19 @@ func TestDecryptAndValidateFwdInfo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid",
|
||||
name: "valid using update add",
|
||||
updateAddBlinding: &btcec.PublicKey{},
|
||||
data: validData,
|
||||
processor: &mockProcessor{},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "valid using payload",
|
||||
payloadBlinding: &btcec.PublicKey{},
|
||||
data: validData,
|
||||
processor: &mockProcessor{},
|
||||
expectedErr: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
|
||||
Reference in new issue
Block a user