Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logistic Regression MVP #2

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Logistic Regression MVP #2

wants to merge 4 commits into from

Conversation

arihantbansal
Copy link
Member

Possible improvements

  • Array inputs for coeff, and input
  • Import existing model weights using some lib and showcase in test (?)

Comment on lines +6 to +59
This project is structured pretty similarly to how a regular Solana Anchor project is structured. The main difference lies in there being two places to write code here:

- The `programs` dir like normal
- The `confidential-ixs` dir for confidential computing instructions

When working with plaintext data, we can edit it inside our program as normal. When working with confidential data though, state transitions take place off-chain using the Arcium network as a co-processor. For this, we then always need two instructions in our program: one that gets called to initialize a confidential computation, and one that gets called when the computation is done and supplies the resulting data. Additionally, since the types and operations in a Solana program and in a confidential computing environment are a bit different, we define the operations themselves in the `confidential-ixs` dir using our Rust-based framework called Arcis. To link all of this together, we provide a few macros that take care of ensuring the correct accounts and data are passed for the specific initialization and callback functions:

```
// confidential-ixs/add_together.rs

use arcis::prelude::*;

arcis_main!();

// mu8 is a masked u8, i.e. an encrypted u8.
#[circuit]
fn add_together(x: mu8, y: mu8) -> mu8 {
x + y
}

// programs/my_program/src/lib.rs

use anchor_lang::prelude::*;
use arcium_anchor::queue_computation;
use arcium_macros::{arcium_callback, callback_accounts, queue_computation_accounts};

declare_id!("<some ID>");

#[program]
pub mod my_program {
use super::*;

pub fn init_computation(_ctx: Context<InitComputation>, input: Vec<u8>) -> Result<()> {
queue_computation(_ctx.accounts, input, vec![])?;
Ok(())
}

#[arcium_callback(circuit = "add_together")]
pub fn add_together_callback(ctx: Context<Callback>, output: Vec<u8>) -> Result<()> {
msg!("Arcium callback invoked with output {:?}", output);
Ok(())
}
}

#[callback_accounts(circuit = "add_together")]
pub struct Callback<'info> {
pub some_extra_acc: AccountInfo<'info>,
}

#[queue_computation_accounts(circuit = "add_together")]
pub struct InitComputation<'info> {
pub some_extra_acc: AccountInfo<'info>,
}
```
Copy link
Member

Choose a reason for hiding this comment

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

This is quite general - a few words about what this sample is about would be better here

predictor/programs/predictor/src/lib.rs Outdated Show resolved Hide resolved
predictor/tests/predictor.ts Outdated Show resolved Hide resolved
predictor/tests/predictor.ts Outdated Show resolved Hide resolved
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