Skip to content

Repository Modernization Plan - Phase 2B: Remove redundant Algorithm() from Opts interfaces#70

Merged
adecaro merged 1 commit into
IBM:mainfrom
Soumya8898:Soumya8898/phase2/simplify-opts
May 25, 2026
Merged

Repository Modernization Plan - Phase 2B: Remove redundant Algorithm() from Opts interfaces#70
adecaro merged 1 commit into
IBM:mainfrom
Soumya8898:Soumya8898/phase2/simplify-opts

Conversation

@Soumya8898
Copy link
Copy Markdown
Contributor

Remove redundant Algorithm() from Opts interfaces

Fixes #63

What

Removes the Algorithm() string method from KeyGenOpts, KeyDerivOpts, and KeyImportOpts interfaces, along with all 11 boilerplate implementations across opts structs.

Why

Every single implementation returned the hardcoded constant "IDEMIX". In a single-algorithm repository, algorithm dispatch via string identifiers is unnecessary overhead. The only two call sites were error messages in impl.go, which now use reflect.TypeOf(opts) for equivalent (and more informative) context.

Changes

File Change
bccsp/types/crypto.go Remove Algorithm() string from KeyGenOpts, KeyDerivOpts, KeyImportOpts
bccsp/types/idemixopts.go Remove IDEMIX constant + 11 Algorithm() method implementations
bccsp/impl.go Replace opts.Algorithm() with reflect.TypeOf(opts) in 2 error messages

Interfaces after this change

type KeyGenOpts interface {
    Ephemeral() bool
}
type KeyDerivOpts interface {
    Ephemeral() bool
}
type KeyImportOpts interface {
    Ephemeral() bool
}

Remove Algorithm() string method from KeyGenOpts, KeyDerivOpts, and
KeyImportOpts interfaces. Every implementation returned the constant
'IDEMIX' unconditionally — a single-algorithm repo has no need for
algorithm dispatch. Also removes the IDEMIX constant and all 11
boilerplate Algorithm() method implementations from opts structs.

Error messages in impl.go now use reflect.TypeOf(opts) for context.

Signed-off-by: Soumya Mohapatra <mohapatras@microsoft.com>
@adecaro adecaro force-pushed the Soumya8898/phase2/simplify-opts branch from 12cceae to 5d32348 Compare May 25, 2026 05:25
@adecaro adecaro self-assigned this May 25, 2026
@adecaro adecaro self-requested a review May 25, 2026 05:26
Copy link
Copy Markdown
Member

@adecaro adecaro left a comment

Choose a reason for hiding this comment

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

LGTM

@adecaro adecaro merged commit 7503bac into IBM:main May 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idemix Repository Modernization Plan

2 participants