Skip to content

Question regarding public key import. #78

@ghostidentity

Description

@ghostidentity

First of all, thanks for providing ML-KEM library for rust.
I'm checking documentation but I'm unable to find a resource on how to marshal encapsulation key (generated from keypair),.

What I want to achieve is that the c# application can initiate a key exchage and the server can return an encapsulation key to generate a sharedkey, in turn the server will consume the cipherText to create its own shared key.

I'm stuck on this challenge: in turn the server will consume the cipherText to create its own shared key.

   // assume the c# application already  receive the publickey and sharedkey, but the server has to consume the cipherText to generate its  own sharedkey
                let decoded_bytes = base64::engine::general_purpose::STANDARD
                    .decode(text.as_bytes())
                    .expect("Failed to decode Base64 private key");
                    const SIZE: usize = 128; 
                    let array: [u8; SIZE] = payload.as_ref().try_into().expect("Slice with incorrect length");
                    let encapsulation_key: EncapsulationKey<MlKem1024Params> = EncapsulationKey::<MlKem1024Params>::from_bytes(array);
                    
                    // Retrieve the encoded ciphertext
                    let encoded_ciphertext = encapsulation_key.as_bytes();
                    let shared_key =dk.decapsulate(&encoded_ciphertext).unwrap();
                    println!("Shared Key: : {:?}", shared_key);
             

                    let encrypted_response = Bytes::from(shared_key);
                let _ = client.publish(reply_to, encrypted_response).await;

Is there a plan to easily export public keys to external system, so its easy to generate shared key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions