light_user_registry/
lib.rs

1use anchor_lang::prelude::*;
2
3declare_id!("6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ");
4
5const USER_ENTRY_SEED: &[u8] = b"user-entry";
6
7#[program]
8pub mod user_registry {
9    use super::*;
10
11    pub fn initialize_user_entry(
12        ctx: Context<InitializeUserEntry>,
13        light_pubkey: [u8; 32],
14        light_encryption_pubkey: [u8; 32],
15    ) -> Result<()> {
16        let user_entry = &mut ctx.accounts.user_entry;
17        user_entry.solana_pubkey = ctx.accounts.signer.key().to_bytes();
18        user_entry.light_pubkey = light_pubkey;
19        user_entry.light_encryption_pubkey = light_encryption_pubkey;
20
21        Ok(())
22    }
23}
24
25#[account]
26pub struct UserEntry {
27    pub solana_pubkey: [u8; 32],
28    pub light_pubkey: [u8; 32],
29    pub light_encryption_pubkey: [u8; 32],
30}
31
32#[derive(Accounts)]
33pub struct InitializeUserEntry<'info> {
34    #[account(mut)]
35    pub signer: Signer<'info>,
36    pub system_program: Program<'info, System>,
37    #[account(
38        init,
39        space = 8 + 32 + 32 + 32,
40        seeds = [USER_ENTRY_SEED, signer.key().to_bytes().as_ref()],
41        bump,
42        payer = signer,
43    )]
44    pub user_entry: Account<'info, UserEntry>,
45}