devide bin and lib

This commit is contained in:
Masato Imai
2022-08-26 13:41:25 +09:00
parent d2dbefe505
commit bf6827de10
6 changed files with 31 additions and 16 deletions

View File

@ -3,7 +3,17 @@ name = "encrypt"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib]
name = "encrypt"
path = "src/lib.rs"
[[bin]]
name = "encrypt"
path = "src/bin.rs"
[[bin]]
name = "elliptic-test"
path = "src/test_main.rs"
[dependencies] [dependencies]
bigdecimal = "0.3.0" bigdecimal = "0.3.0"

View File

@ -1,5 +1,5 @@
fn main() { fn main() {
let a = encrypt(3); let a = encrypt(1);
let b = encrypt2(2); let b = encrypt2(2);
println(decrypt_pair(a * b)); println(decrypt_pair(a * b));
} }

View File

@ -18,6 +18,6 @@ pub struct Args {
#[clap(short, long, takes_value = false)] #[clap(short, long, takes_value = false)]
pub compile: bool, pub compile: bool,
#[clap(short, long, value_parser)] #[clap(short = 'e', long, value_parser)]
pub curve: Option<String>, pub curve: Option<String>,
} }

View File

@ -1,14 +1,7 @@
mod args;
mod client;
mod common;
mod config;
mod elliptic_curve;
mod gpsl;
mod server;
use args::Args;
use clap::Parser; use clap::Parser;
use client::start_client; use encryptlib::args::Args;
use server::start_server; use encryptlib::client::start_client;
use encryptlib::server::start_server;
use std::env; use std::env;
fn main() { fn main() {

7
src/lib.rs Normal file
View File

@ -0,0 +1,7 @@
pub mod args;
pub mod client;
pub mod common;
pub mod config;
pub mod elliptic_curve;
pub mod gpsl;
pub mod server;

View File

@ -5,7 +5,12 @@
[Mod(4767914906170010398, 6139062703770505681), Mod(2445476831433994309, 6139062703770505681)]]] [Mod(4767914906170010398, 6139062703770505681), Mod(2445476831433994309, 6139062703770505681)]]]
*/ */
fn o_main() { use encrypt::{
common::finite_field::FiniteFieldElement, elliptic_curve::elliptic_curve::EllipticCurvePoint,
};
use primitive_types::U512;
fn main() {
let p = U512::from_str_radix("1009", 10).unwrap(); let p = U512::from_str_radix("1009", 10).unwrap();
let secp256_k1_a = FiniteFieldElement::new(U512::from(37u8), p); let secp256_k1_a = FiniteFieldElement::new(U512::from(37u8), p);
@ -45,8 +50,8 @@ fn o_main() {
let ra = U512::from_str_radix("20", 10).unwrap(); let ra = U512::from_str_radix("20", 10).unwrap();
let rad = U512::from_str_radix("26", 10).unwrap(); let rad = U512::from_str_radix("26", 10).unwrap();
let m = U512::from_str_radix("2", 10).unwrap(); let m = U512::from_str_radix("1", 10).unwrap();
let md = U512::from_str_radix("2", 10).unwrap(); let md = U512::from_str_radix("0", 10).unwrap();
let s1 = pp * m + q * ra; let s1 = pp * m + q * ra;
let t1 = pp * ra; let t1 = pp * ra;