Skip to content

Commit 9760848

Browse files
committed
EVM: fix encoding of zero
1 parent 242278c commit 9760848

File tree

1 file changed

+4
-4
lines changed
  • actors/evm/src/interpreter/precompiles

1 file changed

+4
-4
lines changed

actors/evm/src/interpreter/precompiles/evm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ pub(super) fn modexp<RT: Runtime>(
141141
Ok(output)
142142
}
143143

144-
pub(super) fn curve_to_vec(curve: G1) -> Result<Vec<u8>, PrecompileError> {
144+
pub(super) fn curve_to_vec(curve: G1) -> Vec<u8> {
145145
AffineG1::from_jacobian(curve)
146146
.map(|product| {
147147
let mut output = vec![0; 64];
148148
product.x().to_big_endian(&mut output[0..32]).unwrap();
149149
product.y().to_big_endian(&mut output[32..64]).unwrap();
150150
output
151151
})
152-
.ok_or(PrecompileError::EcErr(substrate_bn::CurveError::InvalidEncoding))
152+
.unwrap_or_default()
153153
}
154154

155155
/// add 2 points together on an elliptic curve
@@ -162,7 +162,7 @@ pub(super) fn ec_add<RT: Runtime>(
162162
let point1: G1 = input_params.read_value()?;
163163
let point2: G1 = input_params.read_value()?;
164164

165-
curve_to_vec(point1 + point2)
165+
Ok(curve_to_vec(point1 + point2))
166166
}
167167

168168
/// multiply a point on an elliptic curve by a scalar value
@@ -175,7 +175,7 @@ pub(super) fn ec_mul<RT: Runtime>(
175175
let point: G1 = input_params.read_value()?;
176176
let scalar: Fr = input_params.read_value()?;
177177

178-
curve_to_vec(point * scalar)
178+
Ok(curve_to_vec(point * scalar))
179179
}
180180

181181
/// pairs multple groups of twisted bn curves

0 commit comments

Comments
 (0)