Skip to content

Commit ee0d090

Browse files
authored
Fix public_inputs_hash generation when extra_field not set and serde deserialization bugs. Add google as provider for devnet (aptos-labs#12476)
* fix bugs * update * add google as default provider for chain ids above 100 * fix * use lazy * remove unused deps * lint
1 parent e318636 commit ee0d090

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

aptos-move/vm-genesis/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,21 @@ fn initialize_keyless_accounts(session: &mut SessionExt, chain_id: ChainId) {
582582
]),
583583
);
584584
}
585+
if !chain_id.id() > 100 {
586+
exec_function(
587+
session,
588+
JWKS_MODULE_NAME,
589+
"upsert_oidc_provider",
590+
vec![],
591+
serialize_values(&vec![
592+
MoveValue::Signer(CORE_CODE_ADDRESS),
593+
"https://accounts.google.com".to_string().as_move_value(),
594+
"https://accounts.google.com/.well-known/openid-configuration"
595+
.to_string()
596+
.as_move_value(),
597+
]),
598+
);
599+
}
585600
}
586601

587602
fn create_accounts(session: &mut SessionExt, accounts: &[AccountBalance]) {

types/src/keyless/bn254_circom.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright © Aptos Foundation
22

3+
use super::circuit_constants::MAX_EXTRA_FIELD_BYTES;
34
use crate::{
45
jwks::rsa::RSA_JWK,
56
keyless::{
@@ -14,6 +15,7 @@ use ark_bn254::{Fq, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective};
1415
use ark_ff::PrimeField;
1516
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
1617
use num_traits::{One, Zero};
18+
use once_cell::sync::Lazy;
1719
use serde::{Deserialize, Deserializer, Serialize, Serializer};
1820
use serde_big_array::BigArray;
1921

@@ -22,6 +24,10 @@ use serde_big_array::BigArray;
2224
pub const G1_PROJECTIVE_COMPRESSED_NUM_BYTES: usize = 32;
2325
pub const G2_PROJECTIVE_COMPRESSED_NUM_BYTES: usize = 64;
2426

27+
// When the extra_field is none, use this hash value which is equal to the hash of a single space string.
28+
static EMPTY_EXTRA_FIELD_HASH: Lazy<Fr> =
29+
Lazy::new(|| poseidon_bn254::pad_and_hash_string(" ", MAX_EXTRA_FIELD_BYTES as usize).unwrap());
30+
2531
/// This will do the proper subgroup membership checks.
2632
pub fn g1_projective_str_to_affine(x: &str, y: &str) -> anyhow::Result<G1Affine> {
2733
let g1_affine = G1Bytes::new_unchecked(x, y)?.deserialize_into_affine()?;
@@ -240,7 +246,7 @@ pub fn get_public_inputs_hash(
240246
) -> anyhow::Result<Fr> {
241247
if let EphemeralCertificate::ZeroKnowledgeSig(proof) = &sig.cert {
242248
let (has_extra_field, extra_field_hash) = match &proof.extra_field {
243-
None => (Fr::zero(), Fr::zero()),
249+
None => (Fr::zero(), *Lazy::force(&EMPTY_EXTRA_FIELD_HASH)),
244250
Some(extra_field) => (
245251
Fr::one(),
246252
poseidon_bn254::pad_and_hash_string(

types/src/keyless/openid_sig.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub struct Claims {
174174
#[serde(flatten)]
175175
pub oidc_claims: OidcClaims,
176176
#[serde(default)]
177+
#[serde(flatten)]
177178
pub additional_claims: BTreeMap<String, Value>,
178179
}
179180

0 commit comments

Comments
 (0)