MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / attach_column

Method attach_column

ciphercore-base/src/mpc/mpc_psi.rs:505–533  ·  view source on GitHub ↗

Attach a given shared column to shares of columns

(&mut self, header: &str, column: Node)

Source from the content-addressed store, hash-verified

503
504 // Attach a given shared column to shares of columns
505 fn attach_column(&mut self, header: &str, column: Node) -> Result<()> {
506 match self {
507 Columns::Public(columns) => {
508 if is_shared(&column)? {
509 return Err(runtime_error!("New columns should be public"));
510 }
511 columns.push((header.to_owned(), column));
512 }
513 Columns::Shared(shares) => {
514 if is_shared(&column)? {
515 for (share_id, share) in shares.iter_mut().enumerate() {
516 share.push((header.to_owned(), column.tuple_get(share_id as u64)?));
517 }
518 } else {
519 // If column is public, fake its sharing as (column, 0, 0).
520 let zero_share = zeros_like(column.clone())?;
521 for (share_id, share) in shares.iter_mut().enumerate() {
522 if share_id == 0 {
523 share.push((header.to_owned(), column.clone()));
524 } else {
525 share.push((header.to_owned(), zero_share.clone()));
526 }
527 }
528 }
529 }
530 }
531
532 Ok(())
533 }
534
535 fn extract_and_attach(&mut self, header: &str, columns_shares: &DataShares) -> Result<()> {
536 if columns_shares.column_has_mask(header) {

Callers 2

extract_and_attachMethod · 0.80
instantiateMethod · 0.80

Calls 5

is_sharedFunction · 0.85
zeros_likeFunction · 0.85
cloneMethod · 0.80
pushMethod · 0.45
tuple_getMethod · 0.45

Tested by

no test coverage detected