Skip to content

Enable indexing on eql_v2_encrypted columns without needing function helpers #118

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

Merged
merged 16 commits into from
Jun 25, 2025

Conversation

tobyhede
Copy link
Contributor

No description provided.

@tobyhede tobyhede force-pushed the enable-index-on-hmac_256 branch from e921775 to 6abe92b Compare June 24, 2025 07:08
@tobyhede tobyhede marked this pull request as ready for review June 24, 2025 07:08
@tobyhede tobyhede force-pushed the enable-index-on-hmac_256 branch from 6abe92b to 69afdc8 Compare June 24, 2025 07:17
-- REQUIRE: src/hmac_256/functions.sql


CREATE FUNCTION eql_v2.compare_hmac_256(a eql_v2_encrypted, b eql_v2_encrypted)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between this and blake3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The types are different, although both resolve to text.
The implementation pattern is the same for every type of index for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I mean what do we use them for? HMAC and Blake are essentially the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@coderdan Blake3 is used in the SteVec implementation. I've followed the cipherstash-client implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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


SELECT e FROM ore WHERE id = 42 INTO ore_term;
-- -- EXECUTE 'EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ''("{\"ob\": \"abc\"}")'';' into result;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be removed?

Comment on lines +15 to +17
-- PERFORM eql_v2.log('eql_v2.compare_ore_cllw_u64_8');
-- PERFORM eql_v2.log('a', a::text);
-- PERFORM eql_v2.log('b', b::text);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be removed?

@@ -86,13 +94,13 @@ BEGIN

-- Check if there's a difference
IF x != y THEN
differing := (x, y);
differing := true;
Copy link
Contributor

Choose a reason for hiding this comment

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

By exiting the loop early this may be vulnerable to timing attacks.
The preferred approach is to record the first byte that differs and continue to the end of the input anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@coderdan The exit was in the original code. The only change I made was the unnecessary record. I can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cllw-ore crate has similar issue:

// TODO: More work required to make this constant time

Copy link
Contributor

@coderdan coderdan left a comment

Choose a reason for hiding this comment

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

Epic. No show-stoppers but I'm curious about hmac vs blake. Is Blake just used in JSON indexing?

@tobyhede tobyhede merged commit cb97c93 into main Jun 25, 2025
4 checks passed
@tobyhede tobyhede deleted the enable-index-on-hmac_256 branch June 25, 2025 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants