Skip to content

refactor: extract FFI memory adapters into separate cbmpc/ffi module#75

Merged
hsiuhsiu merged 1 commit intomasterfrom
ffi-seperate
Dec 15, 2025
Merged

refactor: extract FFI memory adapters into separate cbmpc/ffi module#75
hsiuhsiu merged 1 commit intomasterfrom
ffi-seperate

Conversation

@hsiuhsiu
Copy link
Copy Markdown
Contributor

Move C memory allocation/deallocation utilities (cmem_t, cmems_t) from
core/buf and crypto/base_pki into a dedicated ffi module. This separates
FFI-specific concerns from core library types and provides cleaner
abstraction for Go bindings.

Changes:

  • Create src/cbmpc/ffi with cmem_adapter.cpp/h for C memory management
  • Move ffi_kem_ek_t and ffi_kem_dk_t types to ffi/pki.h
  • Update all CGO bindings to use ffi::view() and ffi::copy_to_cmem()
  • Remove to_cmem/from_cmem methods from buf_t and mem_t
  • Remove mems_t class and related FFI conversions from core

Move C memory allocation/deallocation utilities (cmem_t, cmems_t) from
  core/buf and crypto/base_pki into a dedicated ffi module. This separates
  FFI-specific concerns from core library types and provides cleaner
  abstraction for Go bindings.

  Changes:
  - Create src/cbmpc/ffi with cmem_adapter.cpp/h for C memory management
  - Move ffi_kem_ek_t and ffi_kem_dk_t types to ffi/pki.h
  - Update all CGO bindings to use ffi::view() and ffi::copy_to_cmem()
  - Remove to_cmem/from_cmem methods from buf_t and mem_t
  - Remove mems_t class and related FFI conversions from core
@cb-heimdall
Copy link
Copy Markdown

cb-heimdall commented Dec 15, 2025

✅ Heimdall Review Status

Requirement Status More Info
Reviews 2/2
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 2
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 1
Global minimum 0
Max 2
2
1 if commit is unverified 0
Sum 2
CODEOWNERS ✅ None for this change

@hsiuhsiu hsiuhsiu marked this pull request as ready for review December 15, 2025 16:03
Copy link
Copy Markdown

@valery-osheter-cb valery-osheter-cb left a comment

Choose a reason for hiding this comment

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

Approved

@hsiuhsiu hsiuhsiu merged commit 44d3ccf into master Dec 15, 2025
8 checks passed
@hsiuhsiu hsiuhsiu deleted the ffi-seperate branch December 15, 2025 16:38
tankbottoms added a commit to tankbottoms/cb-mpc that referenced this pull request Mar 2, 2026
…oinbase#75)

Move C memory allocation/deallocation utilities (cmem_t, cmems_t) from core/buf and crypto/base_pki into a dedicated ffi module. This separates FFI-specific concerns from core library types and provides cleaner abstraction for Go bindings.

Changes:
- Create src/cbmpc/ffi with cmem_adapter.cpp/h for C memory management
- Move ffi_kem_ek_t and ffi_kem_dk_t types to ffi/pki.h
- Update all CGO bindings to use ffi::view() and ffi::copy_to_cmem()
- Remove to_cmem/from_cmem methods from buf_t and mem_t
- Remove mems_t class and related FFI conversions from core
tankbottoms pushed a commit to tankbottoms/cb-mpc that referenced this pull request Mar 15, 2026
…oinbase#75)

Move C memory allocation/deallocation utilities (cmem_t, cmems_t) from core/buf and crypto/base_pki into a dedicated ffi module. This separates FFI-specific concerns from core library types and provides cleaner abstraction for Go bindings.

Changes:
- Create src/cbmpc/ffi with cmem_adapter.cpp/h for C memory management
- Move ffi_kem_ek_t and ffi_kem_dk_t types to ffi/pki.h
- Update all CGO bindings to use ffi::view() and ffi::copy_to_cmem()
- Remove to_cmem/from_cmem methods from buf_t and mem_t
- Remove mems_t class and related FFI conversions from core
dafisher2000 added a commit to IntegraLedger/cb-mpc that referenced this pull request Mar 23, 2026
Merge coinbase/cb-mpc master (cb60753) into Integra fork:
- PR coinbase#88: constant-time hardening, input validation, prove() error returns
- PR coinbase#84: ZK proof hardening, Fischlin parameter validation
- PR coinbase#75: FFI module extraction (mem_t → ffi::view)
- PR coinbase#71-76: benchmarks, refactoring, CI improvements

Integra customizations preserved:
- derive_child_key() asymmetric HD derivation
- MarshalBinary/UnmarshalECDSA2PCKey/DeriveChild Go API
- P2 server-first protocol support
- WASM build support

Post-merge adaptations:
- Custom CGO bindings updated to use ffi::view() pattern (2 call sites)
- WASM rebuilt with Emscripten (includes Node.js environment support)
- Dockerfile.wasm-build added for reproducible WASM builds

Validated: 19/19 C++ tests, 11/11 Go tests, interactive keygen+sign+derive
(Go P1 ↔ Go P2, WASM P2 ↔ Go P1)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants