-
Notifications
You must be signed in to change notification settings - Fork 0
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
arihantbansal
wants to merge
4
commits into
main
Choose a base branch
from
ml-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cryptopapi997
requested changes
Dec 21, 2024
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>, | ||
} | ||
``` |
There was a problem hiding this comment.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Possible improvements
coeff
, andinput