Skip to content

Celestial Verification Flow: WebRTC proof exchange integration #3

Open
SupremaLex wants to merge 16 commits intomainfrom
celestial-verification-flow
Open

Celestial Verification Flow: WebRTC proof exchange integration #3
SupremaLex wants to merge 16 commits intomainfrom
celestial-verification-flow

Conversation

@SupremaLex
Copy link

@SupremaLex SupremaLex commented Jan 21, 2026

Summary

  • Integrate WebRTC functionality for proof generation and exchange with
    desktop client
  • Add universal PlonkProof parser that works with any circuit
  • Fix passport dataType and zkType dynamic computation
  • Update Registration contract wrapper to v2
  • Configure Eden testnet endpoints and contract addresses

Changes

WebRTC Integration

  • Add WebRTC AAR libraries (webrtc-core, webrtc-firebase)
  • Integrate WebRTC flow into existing QR scanner without new UI screens
  • Add WebRTCProofCoordinator for managing proof exchange flow
  • Add Firebase configuration and authentication support

Proof Handling Improvements

  • Add PlonkProof.fromHexString() for automatic public signal detection
  • Universal parser works with any circuit (registration, query, etc.)

Passport Type Computation

  • Compute dataType dynamically from CircuitAAType structure
  • Compute zkType from circuit name using keccak256 hash

Eden Testnet Configuration

  • Update contract addresses and RPC URLs
  • Change chainId to 3735928814

Add WebRTC functionality for proof generation and exchange with desktop client:
- Add WebRTC AAR libraries (webrtc-core, webrtc-firebase)
- Integrate WebRTC flow into existing QR scanner (no new UI screens)
- Add WebRTCProofCoordinator for managing proof exchange flow
- Add Firebase configuration and auth support
- Fix nested parallel context issue in proof generation
- Add network security config for local development
- Update BaseConfig with development endpoints

This is a work-in-progress implementation. The flow works but needs:
- Additional testing and error handling
- UI feedback improvements
- Production endpoint configuration
- Code cleanup and optimization
Compute passport dataType dynamically from CircuitAAType structure:
- Use dg15DigestPositionShift + aaKeyPositionShift to calculate circuit size
- Build constant name: P_{ALGORITHM}_{HASH}_{SIZE}[_3]
- Example: P_RSA_SHA1_2688 where 2688 = 2432 + 256

Compute zkType from circuit name:
- Convert registerIdentity_X to Z_NOIR_PASSPORT_X
- Apply keccak256 hash using ABI encoding (Hash.sha3String)

Both values now computed correctly instead of using hardcoded constants.
- Add PlonkProof.fromHexString() for automatic public signal detection
- Replace manual proof parsing in ExtIntegratorApiManager with universal function
- Translate Russian comments to English
- Document proof structure: N pub signals * 32 bytes + 2144 bytes proof data

Benefits:
- Works with any circuit (registration, query, etc.)
- Cleaner code: 1 line instead of 30 lines of manual parsing
- Automatically calculates number of public signals
- Better error handling and documentation
- Update contract addresses and RPC URLs for Eden testnet
- Change chainId to 3735928814 for Eden network
- Add current_date field from contract instead of generating locally
- Use real issueTimestamp and identityCounter values
- Fix PlonkProof parser to dynamically detect public signals count
- Fix zkPoints extraction to avoid duplicate 0x prefix
@SupremaLex SupremaLex self-assigned this Jan 21, 2026
@SupremaLex SupremaLex force-pushed the celestial-verification-flow branch from 821bd74 to 95f766e Compare January 23, 2026 13:42
- Update RELAYER_URL to Cloud Run service for both TestNet and Mainnet
- Sync MainnetConfig with TestNet (Eden testnet endpoints and contracts)
- Reorder registerIdentityLight circuits
- Update applicationId to com.grnddsystems.celestials
- Rename package directories and update all imports
- Update google-services.json with new Firebase app
- Rename project to Celestials
- Update WebRTC AAR libraries (race condition fix, TURN servers, reconnect support)
- Add NoirLock global mutex to prevent concurrent native proof generation crashes
- Add duplicate flow protection and state reset on disconnect in WebRTCProofCoordinator
- Add per-step timing logs to query proof generation pipeline for performance profiling
- Remove hardcoded Firebase database URL from WebRTCModule, read from FirebaseApp options
- Update trusted setup URL to zk-celestial-store bucket
- Fix queryIdentity URL typo (vv0.1.0 → v0.1.0)
) {
@OptIn(ExperimentalStdlibApi::class)
suspend fun register(callData: ByteArray, destination: String): RegisterResponseBody {
ErrorHandler.logDebug("RegistrationAPIManager calldata", callData.toHexString())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have any sensitive data here?

import org.web3j.tx.gas.ContractGasProvider;

/**
* <p>Auto generated code.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it is generated from ABI of our contract, correct?

val value = amount

val chainId = 7368L
val chainId = 3735928814L
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to use another chain_id for the mainnet version? If yes, it would be nice to make it part of some config file

ErrorHandler.logError(TAG, "Error calling getProof for certificate registration", e)
throw e
}
certificatesSMTContract.getProof(slaveCertificateIndex).send()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we don't need a try catch here?

@@ -235,144 +207,82 @@ class ProofGenerationManager @Inject constructor(
}

private suspend fun isDocumentRegistered(eDocument: EDocument, proof: UniversalProof): Boolean {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this function always returns false?

val inputs = buildPlonkRegistrationInputs(eDocument, registerIdentityCircuitType)

return withContext(customDispatcher) {
com.grnddsystems.celestials.util.NoirLock.mutex.lock()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it was not called before?

is UniversalProof.Plonk -> {
ErrorHandler.logDebug("RegistrationManager", "Building Plonk registration calldata")

Log.i("UniversalProof.Plonk", zkProof.proof.proof)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How big is this proof?

Use AndroidOpenSSL provider for MD5 instead of BouncyCastle,
add SharedPreferences cache for file hashes to skip redundant
re-computation on unchanged files.
Add shaPrepad() to CircuitUtil for Merkle-Damgård padding outside
the circuit. Add getBlockSizeBytes()/getLengthFieldBytes() helpers
to hash type enums. Fix getChunkNumber() to use correct length
field size for SHA-384/512.
Prepad dg1, dg15, ec, sa with SHA padding before passing to
the circuit, matching the prepadded hash functions on the
circuit side.
Replace local asset loading of query.json with download via
CircuitNoirDownloader. Update circuit download URLs from v0.1.0
to v0.2.0.
…sizing

- Map prime192v1 alias to SECP192R1 curve type in EDocument
- Add prime256v1/secp256r1 with SHA-1 circuit signature types (staticId=20)
- Generalize ECDSA signature parsing to support variable coordinate sizes
  instead of hardcoded 32 bytes
…sion

- Wrap Noir circuit prove calls with NoirLock mutex to prevent concurrent access
- Fix BigInteger.toByteArray() sign byte issue in hex conversion by using
  toString(16) with padding instead of Numeric.toHexString
- Remove verbose diagnostic logs from proof generation
- Send passportHash as passportKey for passports without Active Authentication
- Handle empty aaSignature byte array (not just null) with takeIf check
- Use 0x00 for zero-value fields to avoid JS BigInt(0n) falsy check in Dapp
- Fix decimal-to-hex conversion with proper bytes32 padding
- Remove TIMING logs, verbose diagnostic blocks and redundant debug output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants